import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); Race currentRace = new Race(); int carSpeed; for (int i = 1; i < 4; i++) { System.out.println("â ÐведиÑе название маÑÐ¸Ð½Ñ â " + i); String carName = in.next(); System.out.println("â ÐведиÑе ÑкоÑоÑÑÑ Ð¼Ð°ÑÐ¸Ð½Ñ â " + i); while (!in.hasNextInt()) { System.out.println("â ÐепÑавилÑÐ½Ð°Ñ ÑкоÑоÑÑÑ"); System.out.println("â ÐведиÑе ÑкоÑоÑÑÑ Ð¼Ð°ÑÐ¸Ð½Ñ â " + i); in.next(); } carSpeed = in.nextInt(); while (carSpeed < 0 || carSpeed > 250) { System.out.println("â ÐепÑавилÑÐ½Ð°Ñ ÑкоÑоÑÑÑ"); System.out.println("â ÐведиÑе ÑкоÑоÑÑÑ Ð¼Ð°ÑÐ¸Ð½Ñ â " + i); carSpeed = in.nextInt(); } Car currentCar = new Car(carName, carSpeed); currentRace.setLeader(currentCar); } System.out.println("Ð¡Ð°Ð¼Ð°Ñ Ð±ÑÑÑÑÐ°Ñ Ð¼Ð°Ñина: " + currentRace.leader.name); } } class Car { String name; int speed; public Car(String name, int speed) { this.name = name; this.speed = speed; } } class Race { Car leader; int distance = 0; public void setLeader (Car currentCar) { if (distance < currentCar.speed*24) { distance = currentCar.speed*24; leader = currentCar; } } }