import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Race race = new Race(); for (int i = 1; i <= 3; i++) { System.out.println("ÐведиÑе даннÑе Ð´Ð»Ñ Ð°Ð²ÑÐ¾Ð¼Ð¾Ð±Ð¸Ð»Ñ â" + i + ":"); String name = readCarName(scanner); int speed = readValidSpeed(scanner); Auto auto = new Auto(name, speed); race.determineNewLeader(auto); System.out.println("ÐобедиÑÐµÐ»Ñ Ð³Ð¾Ð½ÐºÐ¸: " + race.getLeaderName()); } } private static String readCarName(Scanner scanner) { System.out.print("ÐведиÑе название авÑомобилÑ: "); return scanner.nextLine(); } private static int readValidSpeed(Scanner scanner) { int speed = 0; boolean validInput = false; while (!validInput) { System.out.print("ÐведиÑе ÑкоÑоÑÑÑ Ð°Ð²ÑÐ¾Ð¼Ð¾Ð±Ð¸Ð»Ñ (0-250 км/Ñ): "); try { speed = Integer.parseInt(scanner.nextLine()); if (speed >= 0 && speed <= 250) { validInput = true; } else { System.out.println("ÐевеÑÐ½Ð°Ñ ÑкоÑоÑÑÑ! ÐопÑобÑйÑе Ñнова."); } } catch (NumberFormatException e) { System.out.println("ÐведÑнное знаÑение не ÑвлÑеÑÑÑ ÑиÑлом. ÐопÑобÑйÑе Ñнова."); } } return speed; } }