New Driver's License
HI! I had completed this task, but I'm not sure that this solution is the best oneïżŒ. Any ideas how to complete this task more professional and easierïżŒ? đ import java.util.Scanner; import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; public class Program { public static void main(String[] args) { Scanner inputs = new Scanner(System.in); String me = inputs.nextLine(); String ag = inputs.nextLine(); String in = inputs.nextLine(); String[] inPeople = in.split(" "); ArrayList<String> otherPeople = new ArrayList<String>(Arrays.asList(inPeople)); otherPeople.add(me); Collections.sort(otherPeople); int myPosition = otherPeople.indexOf(me) + 1; int agents = Integer.parseInt(ag); int timeToWait; switch (agents) { case 1: timeToWait = myPosition * 20; System.out.println(timeToWait); break; case 2: if (myPosition <= 2) { timeToWait = 20; } else if ((myPosition == 3) || (myPosition == 4)){ timeToWait = 40; } else { timeToWait = 60; } System.out.println(timeToWait); break; case 3: if (myPosition <= 3) { timeToWait = 20; } else { timeToWait = 40; } System.out.println(timeToWait); break; case 4: if (myPosition <= 4) { timeToWait = 20; } else { timeToWait = 40; } System.out.println(timeToWait); break; default: timeToWait = 20; System.out.println(timeToWait); } } }