hi i have this assingment due very soon and i am totally stumped. I have to use java and im not good with it at all , ive' been searching everywhere and i can't find anything that would help me. Hopefully you guys can help me , thanks in advance.
i am suppose to do this.
Write a program that does the following.
Ask the user how much data they have
For every number entered print the number and whether it was larger or smaller, and by how much, than the previous number.
Compare the first number to 0.
for example, (comparing to first number (0) 10, 10 greater // 20, 10 greater // 50, 30 greater.
this is what i have so far :
{public static void main(String[] args)
{int num1=0,nnum,subvalue,addvalue,sum,counter;
Scanner input = new Scanner(System.in);
System.out.print("how much data do you have? ");
counter=input.nextInt();
counterkb=counter+kb.nextInt();
num1=input.nextInt();
System.out.print("enter a number");
nnum=input.nextInt();
subvalue=num1-nnum;
addvalue=num1+nnum;
for (num1=1;counter<=counter+kb;nnum=num1+1)
{sum=num1+nnum;}
System.out.println("The sum is" +sum);
if(num1>nnum);
{System.out.print(num1 +" is greater than nnum by "+subvalue);
{
if(num1<nnum);
{ System.out.print(nnum +" is less than num1 by "+addvalue);
}
}
}
}
}
i think the program should be really simple. we did not learn any strings or arrays, really basic java. im not sure how i am suppose to output weather the number was greater/less than how many. and i am not sure how i am suppose to set the counter and loop// + what loop i should use. any help would be greatly appreciated. thanks in advance again.