【发布时间】:2014-10-06 05:59:05
【问题描述】:
我刚刚开始学习 java,但我似乎无法找到一种方法来使用 for 循环进行简单的用户输入。假设我必须输入未知数量的硬件分数,但直到用户实际输入时我才知道。问题是我必须添加用户输入的分数。我该如何去循环问题的扫描器部分。
import java.util.Scanner;
public class HomeworkCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter the homework scores:");
double hwScores = scanner.nextDouble();
//how can I loop through the number of homework added on plus
//add the sum and find the average?
【问题讨论】:
标签: java