import java.util.Scanner; public class Main { private static class Car{ private String name; private int speed; public Car(String name, int speed) { this.name = name; this.speed = speed; } public String getName() { return name;} public int getSpeed() { return speed; } } private static class Race{ public static String leader(Car[] nameMassive) { int d=0; String nameLeader=null; int distance=0; for (int i=0; i<3; i++){ d = 24 * nameMassive[i].getSpeed(); if (distance < d) { distance = d; nameLeader=nameMassive[i].getName(); } } System.out.println("Ð¡Ð°Ð¼Ð°Ñ Ð±ÑÑÑÑÐ°Ñ Ð¼Ð°Ñина: "+ nameLeader); return nameLeader; } } public static void main(String[] args) { System.out.println("Hello world!"); Car[] allCars = new Car[3]; Scanner scanner = new Scanner(System.in); for (int i=0; i<3; i++){ System.out.println("ÐведиÑе название авÑÐ¾Ð¼Ð¾Ð±Ð¸Ð»Ñ â "+(i+1)+" :"); String carName = scanner.nextLine().trim(); if(carName.isEmpty()) { System.out.println("ÐÑ Ð½Ðµ вели название авÑомобилÑ"); System.out.println("ÐведиÑе коÑÑекÑное название авÑÐ¾Ð¼Ð¾Ð±Ð¸Ð»Ñ â "+(i+1)+" :"); carName = scanner.nextLine().trim(); } int carSpeed=-1; while ( (carSpeed<0) || (carSpeed>250)){ System.out.println("ÐведиÑе ÑкоÑоÑÑÑ Ð°Ð²ÑÐ¾Ð¼Ð¾Ð±Ð¸Ð»Ñ â " + (i + 1) + " :"); //пÑовеÑка ÑÑо ÑиÑло Ñелое - ÐºÐ¾Ð½ÐµÑ while (!scanner.hasNextInt()) { System.out.println("СкоÑоÑÑÑ Ð´Ð¾Ð»Ð¶Ð½Ð° бÑÑÑ ÑелÑм ÑиÑлом. ÐовÑоÑиÑе ввод: "); scanner.next(); // оÑиÑаем некоÑÑекÑнÑй ввод } // пÑовеÑка ÑÑо ÑиÑло Ñелое - ÐºÐ¾Ð½ÐµÑ carSpeed=scanner.nextInt(); if((carSpeed<0) || (carSpeed>250)) { System.out.println("ÐепÑавилÑÐ½Ð°Ñ ÑкоÑоÑÑÑ. ÐведиÑе знаÑение Ð¾Ñ 0 до 250! "); } } allCars[i] = new Car(carName, carSpeed); scanner.nextLine(); } scanner.close(); Race.leader(allCars ); } }