Hello. Purpose: a program that generates two random numbers from a specified range, compares them. If not equal, displays the message: "Not equal, attempt No.-X" and suggests new integers. This will end when Random ints match.
public class GonaNumber{ public static void main(String[]args){ String stars = (************); int numGuess = 0;// счетчик попыток //первое сравниваемое число int randomA = (int)(Math.random()*10+1); //второе сравниваемое число int randomB = (int)(Math.random()*10+1); System.out.println(stars); System.out.println("Загадываем числа для сравнения"); System.out.println(stars); numGuess++; while(randomA != randomB){ System.out.println("Хм не в этот раз... Попытка номер "+numGuess); numGuess++ } System.out.println("Совпали на "+numGuess+" попытке"); } I stopped the computer in the second minute of the launch of the program, then it dawned that I compared the same numbers five million times.