【发布时间】:2013-05-18 02:37:58
【问题描述】:
我正在尝试编写一个 java 程序来执行以下操作:
- 提示并读入要读取的整数个数
- 创建一个可以容纳这么多整数的数组
- 使用循环读取整数值以填充数组
- 计算数组中的平均值(作为整数)
这是我目前所拥有的(尽管我很确定这是错误的):
public static void Average (Scanner keyboard)
{
System.out.println("Please insert number of integers to read in: ");
keyboard = new Scanner(System.in);
int f = keyboard.nextInt();
int value[]= new int[f];
//I don't know if I should use a while loop here or what the arguments should be
}
为了建立循环应该满足什么条件?
【问题讨论】: