MAIN.JAVA:
import java.util.*; public class Main { public static void main(String[] args){ //fill your code here String[] events; String input; Scanner scan = new Scanner(System.in); System.out.println("Enter the number of events:"); int noOfEvent = scan.nextInt(); scan.nextLine(); TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>(); System.out.println("Enter event details in CSV(Customer Name, Ticket Price, No of Seats Booked)"); for (int i = 0; i < noOfEvent; i++) { input = scan.nextLine(); events = input.split(","); String name = events[0]; Integer price = Integer.parseInt(events[1]); Integer seatBooked = Integer.parseInt(events[2]); if (map.containsKey(price)) { Integer seat = map.get(price); map.put(price, (seat+seatBooked)); } else { map.put(price, seatBooked); } } System.out.println("Ticket Price Tickets Booked"); for(Map.Entry m:map.entrySet()) { System.out.printf("%-15s%s\n",m.getKey(),m.getValue()); } } }