I need help with a programming assignment
The part that i need to add the exception are in bold.import java.util.ArrayList;import java.util.Scanner;import java.io.*;public class Main {static ArrayList<String> name = new ArrayList<String>();static ArrayList<String> id = new ArrayList<String>();static ArrayList<String> state_of_employee = new ArrayList<String>();static ArrayList<String> hourly_worked = new ArrayList<String>();static ArrayList<String> state_of_student_employee = new ArrayList<String>();static ArrayList<String> pay_rate = new ArrayList<String>();static Scanner in = new Scanner(System.in);private static Scanner inp;static StudentEmployee[] Obb = new StudentEmployee[50]; public static void main(String[] args) { inp = new Scanner(System.in); file_Operation(); char choice; do{ System.out.print("===================Menu================="); System.out.print("\nEnter:\n"+" S to Show.\n"+" A to Add.\n"+" R to Remove.\n" + " N to Sorted-by-name.\n"+ " T to Sorted-by-rate.\n"+" W to Student-isWorkStudy\n" + " H to Show-highest.\n"+" L to Show-lowest.\n"+" C to Change-rate id/name xxx\n" + " B to Rate x between y (bonus).\n"+" E to Exit.\n" + "Enter your choice : "); choice = inp.next().charAt(0); switch(choice){ case 'S' : Show(); break; case 'A' : Add(); break; case 'R' : Remove(); break; case 'W' : StudentIsWorkStudy();break; case 'N' : SortByName(); break; case 'T' : SortByRate(); break; case 'H' : ShowHighest(); break; case 'L' : ShowLowest(); break; case 'C' : ChangeRate(); break; case 'B' : Rate(); break; case 'E' : break; default : System.out.println("Error, Enter a valid key with capital letter"); break; } }while(choice != 'E'); System.out.println("================================================"); System.out.print("Thank you");}public static void file_Operation(){ String[] words = null; FileReader fr = null; BufferedReader br = null; String line = null ; try{ fr = new FileReader("semployees.csv"); br = new BufferedReader(fr); line = (String)br.readLine(); while(line!=null){ words = line.split(","); name.add(words[0]); id.add(words[1]); state_of_employee.add(words[2]); hourly_worked.add(words[3]); state_of_student_employee.add(words[4]); pay_rate.add(words[5]); line = (String)br.readLine(); } br.close(); fr.close(); }catch(Exception ex){ System.out.println(ex); }}public static void Show(){ System.out.println("================================================"); for ( int i = 0 ; i < name.size(); ++ i ) { System.out.println( "name: "+ name.get(i) + "\nid: "+id.get(i) +"\nstate of employee: "+ state_of_employee.get(i) + "\nHourly Worked: "+hourly_worked.get(i) +"\nstate of student employee: "+ state_of_student_employee.get(i) + "\nPay Rate: "+pay_rate.get(i) ); System.out.println("================================================"); }}public static void Add(){ int n; System.out.print("Enter the number of person you want add : "); n = inp.nextInt(); for(int i=0 ; i<n ; i++){ System.out.print((i+1)+"-Enter Name: "); name.add((String)in.nextLine()); System.out.print((i+1)+"-Enter ID: "); id.add((String)in.nextLine()); in = new Scanner(System.in); System.out.print((i+1)+"-Enter state of employee: "); state_of_employee.add((String)in.nextLine()); System.out.print((i+1)+"-Hourly Worked: "); hourly_worked.add((String)in.nextLine()); System.out.print((i+1)+"-state of student employee: "); state_of_student_employee.add((String)in.nextLine()); System.out.print((i+1)+"-Pay Rate: "); pay_rate.add((String)in.nextLine()); System.out.println("================================================"); } }public static void Remove(){ int nn; String empid; int index; System.out.print("Enter how many Employees you want ot remove: "); nn = inp.nextInt(); for(int i=0 ; i<nn ; i++){ System.out.print((i+1)+"-Enter ID of Employee to remove: "); empid = in.nextLine(); index = id.indexOf(empid); name.remove(index); id.remove(index); hourly_worked.remove(index); state_of_student_employee.remove(index); state_of_employee.remove(index); pay_rate.remove(index); System.out.println("Deleted"); }} public static void Rate(){ int x=0; int y=0; System.out.println("================================================"); System.out.println("Show the student employees that with the hourly rate between x and y"); System.out.println("Note, Should x<y "); System.out.print("Enter x : "); in = new Scanner(System.in); x = in.nextInt(); System.out.print("Enter y : "); in = new Scanner(System.in); y = in.nextInt(); System.out.println("===Employees's rate between =="+x+" and "+y+"========="); for ( int i = 0 ; i < name.size(); ++ i ){ if(Integer.parseInt(hourly_worked.get(i)) >= x && Integer.parseInt(hourly_worked.get(i)) <= y){ System.out.println("name: "+ name.get(i)); } } System.out.println("================================================"); } public static void ShowHighest(){ int max = Integer.parseInt(hourly_worked.get(0)); int IndexHigh=0; for ( int i = 0 ; i < name.size(); ++ i ){ if(Integer.parseInt(hourly_worked.get(i)) > max){ max = Integer.parseInt(hourly_worked.get(i)); IndexHigh = i; } } System.out.println("================================================"); System.out.println("The student employee with highest hourly rate is: "+ name.get(IndexHigh)); } public static void ShowLowest (){ int min = Integer.parseInt(hourly_worked.get(0)); int IndexLow=0; for( int i = 0 ; i < name.size(); ++ i ){ if(Integer.parseInt(hourly_worked.get(i)) < min){ min = Integer.parseInt(hourly_worked.get(i)); IndexLow = i; } } System.out.println("================================================"); System.out.println("The student employee with lowest hourly rate is: "+ name.get(IndexLow)); } public static void StudentIsWorkStudy(){ System.out.println("All the students that are eligible for work study status"); for ( int i = 0 ; i < name.size(); ++ i ){ if(Boolean.parseBoolean(state_of_student_employee.get(i))){ System.out.println("Name : "+name.get(i)); } } } public static void ChangeRate(){ int idd=0; System.out.println("================================================"); System.out.print("Enter the id of the Employee that's you want to change here rate: "); in = new Scanner(System.in); idd = in.nextInt(); int i=0; while(idd != Integer.parseInt(id.get(i))){ i++; } double newPayrate; System.out.print("Enter the new rate : "); in = new Scanner(System.in); newPayrate = in.nextDouble(); pay_rate.set(i, Double.toString(newPayrate)); System.out.println("Changed"); } public static void SortByName(){ String temp; String names[] = new String[name.size()]; for(int i = 0; i < name.size(); i++){ names[i] = name.get(i); } for (int i = 0; i < name.size(); i++) { for (int j = i + 1; j < name.size(); j++) { if (names[i].compareTo(names[j])>0) { temp = names[i]; names[i] = names[j]; names[j] = temp; } } } System.out.println("================================================"); for ( int i = 0 ; i < name.size(); ++ i ){ System.out.println("name: "+ names[i]);} System.out.println("================================================"); } public static void SortByRate(){ Double temp; Double rate[] = new Double[name.size()]; for(int i = 0; i < name.size(); i++){ rate[i] = Double.parseDouble(pay_rate.get(i)); } for (int i = 0; i < name.size(); i++) { for (int j = i + 1; j < name.size(); j++) { if (rate[i].compareTo(rate[j])>0) { temp = rate[i]; rate[i] = rate[j]; rate[j] = temp; } } } System.out.println("================================================"); for ( int i = 0 ; i < name.size(); ++ i ){ System.out.println("Rate : "+ rate[i]);} System.out.println("================================================"); }}
THIS QUESTION IS UNSOLVED!
Request a custom answer for this question