如何以简单的方式打印存储在数组中的内容。在过去的 3 个小时里,我一直盯着这个看!
import java.util.Scanner;
public class December2012 {
public static void main(String[] args) {
int[] array = new int[100];
int sum = 0;
int i = 0;
Scanner input = new Scanner(System.in);
while (sum <= 100 && i < array.length) {
System.out.print("Write in the " + (i + 1) + "th number: ");
array[i] = input.nextInt();
sum += array[i];
i++;
}
System.out.print("You added: ");
System.out.print(array[i] + " ");
System.out.println("\nsum is " + sum);
}
}