Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey I was wondering if I could have someone help me with my java programing. I n

ID: 675476 • Letter: H

Question

Hey I was wondering if I could have someone help me with my java programing. I need help write this problem out in code.

Part a - Create a collegeCourse class. The class contains fields for the course ID (for example, "CIS 210"), credit hours (for example, 3), and a letter grade (for example, 'A'). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get () and set () method for the Student ID number. Also create a get () method that returns one of the Student's CollegeCourses; the method takes an integer argument and returns the CollegeCourse in that position (0 through 4). Next, create a set () method that sets the value of one of the Student's CollegeCourses; the method takes two arguments - a collegeCourse and an integer representing the CollegeCourse's position (0 through 4).

Part b - Write an application that prompts a professor to enter grades for five different courses each for 10 students. Prompt the professor to enter data for one student at a time, including student ID and course data for five courses. Use prompts containing the number of the student whose data is being entered and the course number - for example, "Enter ID for student #s", where s is an integer from 1 through 10, indicating the student, and "Enter course ID #n", where n is an integer from 1 through 5, indicating the course number. Verify that the professor enters only A, B, C, D, or F for the grade value for each course.

Explanation / Answer

Part (a).

public class collegeCourse {  
   String courseId=null;
   int creditHours;
   char grade;
  
   public String getCourseId() {
       return courseId;
   }
   public void setCourseId(String courseId) {
       this.courseId = courseId;
   }
   public int getCreditHours() {
       return creditHours;
   }
   public void setCreditHours(int creditHours) {
       this.creditHours = creditHours;
   }
   public char getGrade() {
       return grade;
   }
   public void setGrade(char grade) {
       this.grade = grade;
   }
}

public class Student {
   int studentId;
   collegeCourse cc[5];

   public int getStudentId() {
       return studentId;
   }

   public void setStudentId(int studentId) {
       this.studentId = studentId;
   }
  
   public String get(int n)
   {
       return cc[n];
   }

   public void get(int n, String sub)
   {
       cc[n]=sub;
   }
}


Part (b).

public static void main()
{
   Scanner in = new Scanner(System.in);
   Student[] stu = new Student[10];
  
   int i, j;
   for(i=0; i<10; i++)
   {
       System.out.println("Enter ID for student " + (i+1));
       stu[i].studentId = in.nextLine();
       for(j=0; j<5; j++)
       {
           System.out.println("Enter course ID for #" + (j+1));
           stu[i].cc[j].courseId = in.nextLine();
           System.out.println("Enter Credit Hours for #" + (j+1));
           stu[i].cc[j].creditHours = in.nextInt();
           System.out.println("Enter Grade for #" + (j+1));
           stu[i].cc[j].grade = in.next();

if(stu[i].cc[j].grade == "A" || stu[i].cc[j].grade == "B" || stu[i].cc[j].grade == "C" || stu[i].cc[j].grade == "D" || stu[i].cc[j].grade == "F")

{

}
else
{

  System.out.println("Wrong Grade entered. Valid grades are A/B/C/D/F");

}
       }
   }  
}