·It captures the “NumberFormatException” that is thrown if a string cannot be converted to a number. When the exception is captured, the user must be informed that he is an idiot.
·Define a new exception called “NotMemberException”. The exception must be thrown if the registration number entered by the user does not exist in the list of StudInfo. Your program should catch the exception as follows. It should first try to see if the number before and after the one entered exists. If so, it informs the user that they probably made a typo and provides them the name of the found student. If neither is found it must simply inform the user that such registration number does not exist.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author christoforos
*/
public class Main {
/**
* @param args the command line arguments
*/
static ArrayList<StudInfo> ls;
public static void main(String[] args) {
populate();
System.out.println("Enter a registration number:");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
String inp = in.readLine();
int rVal = Integer.parseInt(inp);
StudInfo foundStudent = getStudent(rVal);
System.out.println(foundStudent.getName());
}
catch(IOException ioe) {System.out.println(ioe.getMessage());}
}
static void pop
1
Expert's answer
2012-11-12T05:54:30-0500
Unfortunately, your question requires a lot of work and cannot be done for free. Submit it with all requirements as an assignment to our control panel and we'll assist you.
Comments
Leave a comment