I have to:
- create this java array;
- loop through it using a while loop;
- terminate the program if the sum adds up to 100;
- and print the sum and the numbers that I did put into the array.
I can't figure out how to do that, here is my code so far, any help would be appreciated.
public class december2012 {
public static void main(String[] args) {
int sum=0;
Scanner input = new Scanner(System.in);
int i=1;
int [] array = new int[i];
while( i > array.length || sum <= 100) {
System.out.println("Write in the " + i + " number") ;
array[i]=input.nextInt();
sum=+array[i];
System.out.println("sum is " + sum);
}
}
}