fork(4) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int sum=0;
  13. Scanner input = new Scanner(System.in);
  14. int i = 0; // array starts from 0
  15. int [] array = new int[100]; // create larger array
  16. while(i < array.length && sum <= 100) // i should be less then length
  17. {
  18. System.out.println("Write in the " + i + " number") ;
  19. array[i] = input.nextInt();
  20. sum += array[i];
  21. System.out.println("sum is " + sum);
  22. i++; // increment i
  23. }
  24. }
  25. }
Success #stdin #stdout 0.1s 380736KB
stdin
45
4
6
7
68
stdout
Write in the 0 number
sum is 45
Write in the 1 number
sum is 49
Write in the 2 number
sum is 55
Write in the 3 number
sum is 62
Write in the 4 number
sum is 130