
Hi, I really appreciate the help I have gotten,I have 3 more problems to go by Monday.I will need help with all three. I hope someone is willing to help. So far I have found this web site to be the best for help, other sites I have tried only look down at you and give you attitude.I got sick mid way through this course and have found it impossible to catch up with all my other classes and the semester closes Monday.In this problem I have to write an application that displays a series of at least 10 student ID numbers (that are to be stored in an array) and asks the user to enter a test letter grade for the student. Create an Exception class named GradeException that contains a static public array of valid letter grades('A''B','C','D','F',and 'I'), which you can use to determine whether a grade entered from the application is valid. In the application, throw a Grade Exception if the user does not enter a valid letter grade. Catch the GradeException, and then display an appropriate message.In addition, store an 'I' for (incomplete)for any student whom an exception is caught. At the end of the application, display all the student IDs and grades. Save them as GradeException.java and TestGrade.java.I have got the code for 1 student, but I'm not sure about array and the rest.I think I have figured out the other two questions, but I am still stuck on this one. Here is the code I have:
public class GradeException extends Exception
{
public GradeException(String s)
{
super(s);
}
}
public class TestGrade
{
public static void main(String args[]) throws Exception
{
int id;
int grade;
String grades = new String();
try{
id = 123;
System.out.println("Student id number: " + id);
System.out.println("Enter the grade for the above student id number.");
grade = (char)System.in.read();
grades = String.valueOf((char)grade);
if(grade != 'A' && grade != 'B' && grade != 'C' &&
grade != 'D' && grade != 'F'&& grade !='I')
throw (new GradeException(grades));
System.out.println("The id and grade for this student is:");
System.out.println(" " + id + " " + (char)grade);
}
catch(GradeException e)
{
System.out.println("Invalid grade - " + e.getMessage());
}
}
}

Hi Friend,
Try the following code:
import java.util.*;
class GradeException extends Exception{
public GradeException(String s){
System.out.println(s);
}
}
public class TestGrade{
int id;
String grade;
TestGrade(int id,String grade){
this.id=id;
this.grade=grade;
}
public int getId(){
return id;
}
public String getGrade(){
return grade;
}
public static void main(String args[]) throws Exception{
ArrayList<TestGrade> list = new ArrayList<TestGrade>();
Scanner input=new Scanner(System.in);
int ide;
String grade="";
String grades[] ={"A","B","C","D","F","I"};
List l=Arrays.asList(grades);
for(int i=0;i<2;i++){
System.out.println("Enter Student id: ");
ide=input.nextInt();
System.out.println("Enter the grade for the above student id number:");
grade = input.next();
if(!l.contains(grade)){
new GradeException("You have entered invalid grade!Re-enter Grade:");
grade = input.next();
}
list.add(new TestGrade(ide,grade));
}
System.out.println("ID Marks");
for (TestGrade test : list){
System.out.println(test.getId()+" "+test.getGrade());
}
}
}
Thanks

Hi Friend, I am truly indebted to you. I had tried running the application and saving the files as GradeException and TestGrade as you suggested the first time around. You were absolutely correct, the problem I had was that I pivked up something when I copied and pasted. When I retyped the code and ran it as such it worked perfectly. Nonetheless, I got the assignment in on time along with my others and passed the class. I thank you very much.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.