Al. Bcard.quoted16 kun oldin
public class Listing4_4 {

public static void main (String [] args) {

Random rnd = new Random(System.currentTimeMillis ());

int secret = 1 + rnd.nextInt (10);

int userData;

String userInput;

while (true) {

// Выводим окно запроса

userInput = JOptionPane.showInputDialog («Угадайте число от 1 до 10»);

// Преобразуем строку в число в явном виде

userData = Integer.parseInt (userInput);

if (userData == secret) {

JOptionPane.showMessageDialog (null, «Вы угадали число!»);

break;

}

}

}

}
  • Fikr bildirish uchun kirish yoki roʻyxatdan oʻtish