このプログラムを正しく実行することができません。数字を入力しても何も起こりません。誰かが間違っているところを指摘できますか?偶数と奇数のカウント数
import java.util.Scanner;
public class EvenOdd {
public static void main(String[] args) {
//Declare variables
int number;
int evenNumbers = 0;
int oddNumbers = 0;
String answer = " ";
//Create Scanner
Scanner input = new Scanner(System.in);
do {
//Prompt the user to enter a list of positive numbers with the last being a negative
System.out.println("Please enter a list of positive numbers separated by a space.");
System.out.println("(Enter a negative number after all positive numbers have been entered.)");
//Read the users numbers
number = input.nextInt();
//An if statement determing a number either even or odd
while (number >= 0) {
if (number % 2 == 0) {
evenNumbers++;
} else {
oddNumbers++;
}//end of else
//Read next number
number = input.nextInt();
}//end of while
//Display total number of even and odd integers
System.out.println("The total number of even positive intergers is: " + evenNumbers);
System.out.println("The total number of odd positive integers is: " + oddNumbers);
//Ask the us if they would like to play again
System.out.println("Would you like to play again? Please type: 'yes' or 'no': ");
//Move scanner to next line
input.nextLine();
//Read the users input
answer = input.nextLine();
} while(answer.equalsIgnoreCase("yes")); //end of do-while
}//end of main
}//end of class
'this program':プログラムはどこですか? – RyanZim
ライン37が原因です –
今日は宿題の数が多い新学期でなければなりません。 – epascarello