0
import java.util.Random; импорт java.util.Scanner;Set sentinel value java code
общественного класс ArithmeticGame {
static int right = 0;
static int wrong = 0;
static int total = 0;
static int per = 0;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
Random num = new Random();
Random num1 = new Random();
int r = 0;
while (r != 999) {
total++;
per = (right/total) * 100;
int a = num.nextInt(20);
int b = num1.nextInt(20);
int sum = a + b;
System.out.println(" \n ARITHETIC GAME!");
System.out.println("What is the sum of " + a + " + " + b + " ?");
r = s.nextInt();
if (r == sum) {
System.out.println("Your answer is correct.");
right++;
}
if (r != sum) {
System.out.println("OOPS! Your answer is Wrong");
wrong++;
}
System.out.println("So far you have " + right + " right answers " + wrong + " wrong answers out of total "
+ total + " questions");
}
}
} Мне нужно установить значение дозорного, так что, когда я вхожу 999 программа должна прекратить и ответ 999 не засчитывались конечным значение.
Вам нужно объяснить, что происходит неправильно – fdsa