Hi all,
Im new to the forum. I really need some help on this program i am doing. Im currently trying to teach myself java so i have some knowledge for my upcoming college class. My current program deals with arrays. It is suppose to prompt the user, a college professor, to enter 10 student IDs, and then a grade for a certain course, which it asks for the course grade only 5 times. I finally got this to compile after a lot of time spent on it. My issue is that it completely skips the entering student ID's and goes straight to entering the grade and im not sure why. This probably isnt the only problem but its the current problem i am having. Here is my code:
I really appreciate any help with this.import java.io.*; public class InputGrades { private int idGrade; public CollegeCourse[] courses = new CollegeCourse[5]; public InputGrades(int gradeID) { idGrade = gradeID; courses[0] = new CollegeCourse('A', "CIS 210", 3); courses[1] = new CollegeCourse('B', "CIS 211", 2); courses[2] = new CollegeCourse('C', "CIS 212", 2); courses[3] = new CollegeCourse('D', "CIS 213", 3); courses[4] = new CollegeCourse('F', "CIS 214", 1); } public static void main(String[] args) throws IOException { InputGrades inputgrades = new InputGrades(1); char value; boolean match = false; BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); for (int s = 1; s <= 10; s++) { System.out.println("Enter ID for student#: " + s); } for (int n = 1; n <= 5; n++) { System.out.print("\tEnter grade for course ID#" + n + ": " + inputgrades.courses[x].getCourseID()); value = stdin.readLine().charAt(0); if ((value == 'A') || (value == 'B') || (value == 'C') || (value == 'D') || (value == 'F')) { match = false; } else { System.out.println("Please re-enter the grade"); match = true; --n; } } } }
Thanks,
Sam