Question

A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 21...

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 CollegeCourse objects; the method takes two arguments—a CollegeCourse and an integer representing the CollegeCourse’s position (0 through 4).

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 #1, and Enter course ID #5. Verify that the professor enters only A, B, C, D, or F for the grade value for each course. After all the data has been entered, display all the information in order by student then course as shown:

Student #1  ID #101
CS1 1  -- credits. Grade is A
CS2 2  -- credits. Grade is B
CS3 3  -- credits. Grade is C
CS4 4  -- credits. Grade is D
CS5 5  -- credits. Grade is F

CollegeCourse.java

public class CollegeCourse {
private String courseID;
private int credits;
private char grade;
public String getID() {
}
public int getCredits() {
}
public char getGrade() {
}
public void setID(String idNum) {
}
public void setCredits(int cr) {
}
public void setGrade(char gr) {
}
}

InputGrades.java

import java.util.*;
public class InputGrades {
public static void main(String[] args) {
// Write your code here
}
}

Student.java

public class Student {
private int stuID;
private CollegeCourse[] course = new CollegeCourse[5];

public int getID() {
}
public CollegeCourse getCourse(int x) {
}

public void setID(int idNum) {
}
public void setCourse(CollegeCourse c, int x) {
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CollegeCourse.java


public class CollegeCourse {
  
   private String courseID;
   private int credits;
   private char grade;
   public String getCourseID() {
       return courseID;
   }
   public void setCourseID(String courseID) {
       this.courseID = courseID;
   }
   public int getCredits() {
       return credits;
   }
   public void setCredits(int credits) {
       this.credits = credits;
   }
   public char getGrade() {
       return grade;
   }
   public void setGrade(char grade) {
       this.grade = grade;
   }

}


Student.java


public class Student {
   private int stuID;
   private CollegeCourse[] course = new CollegeCourse[5];
   public int getStuID() {
       return stuID;
   }
   public void setStuID(int stuID) {
       this.stuID = stuID;
   }
   public CollegeCourse getCourse(int x)
   {
       return course[x];
   }
   public void setCourse(CollegeCourse c,int x)
   {
       course[x] = c;
   }

}


InputGrades.java

import java.util.Scanner;

public class InputGrades {

   public static void main(String[] args) {
      
       Student[] s = new Student[10];
       Scanner sc = new Scanner(System.in);
       CollegeCourse c = new CollegeCourse();
       for(int i=0;i<10;i++)
       {
           System.out.println("Enter ID for Student #"+(i+1));
           s[i] = new Student();
           s[i].setStuID(sc.nextInt());
          
           for(int j=0;j<5;j++)
           {
               System.out.println("Enter course ID #"+(j+1));
               c.setCourseID(sc.next());
               System.out.println("Enter credits for "+c.getCourseID());
               c.setCredits(sc.nextInt());
               System.out.println("Enter grade for "+c.getCourseID());
               c.setGrade(sc.next().charAt(0));
               s[i].setCourse(c, j);
              
           }
       }
      
       for(int i=0;i<1;i++)
       {
           System.out.println("Student #"+(i+1) +" ID #"+s[i].getStuID() );
           for(int j=0;j<5;j++)
           {
               System.out.println(s[i].getCourse(j).getCourseID()+ " "+s[i].getCourse(j).getCredits()+" credits.Grade is " +s[i].getCourse(j).getGrade());
           }
       }

   }

}


Output

Enter ID for student #1 101 Enter course ID #1 CS101 Enter credits for cs101 Enter grade for cs101 Enter course ID #2 cs102 E

*output has been taken for only one student instead of 10, but code is working for 10 students also. you need not change anything*

Add a comment
Know the answer?
Add Answer to:
A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 21...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS...

    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...

  • A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS...

    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...

  • Create an abstract Student class for Parker University. The class contains fields for student ID number,...

    Create an abstract Student class for Parker University. The class contains fields for student ID number, last name, and annual tuition. Include a constructor that requires parameters for the ID number and name. Include get and set methods for each field; the setTuition() method is abstract. Create three Student subclasses named UndergraduateStudent, GraduateStudent, and StudentAtLarge, each with a unique setTuition() method. Tuition for an UndergraduateStudent is $4,000 per semester, tuition for a GraduateStudent is $6,000 per semester, and tuition for...

  • Modify the objectstudent JAVA program to add a private variable zipcode, you must also add setters...

    Modify the objectstudent JAVA program to add a private variable zipcode, you must also add setters and getter methods for the new variable and modify the toString method. The objectstudent program is in this weeks module, you can give it a default value of 19090. class Student { private int id; private String name; public Student() { id = 8; name = "John"; } public int getid() { return id; } public String getname() { return name; } public void...

  • Java Do 72a, 72b, 72c, 72d. Code & output required. public class Employee { private int...

    Java Do 72a, 72b, 72c, 72d. Code & output required. public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...

  • Writing 3 Java Classes for Student registration /** * A class which maintains basic information about...

    Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course {    /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...

  • (To be written in Java code) Create a class named CollegeCourse that includes the following data...

    (To be written in Java code) Create a class named CollegeCourse that includes the following data fields: dept (String) - holds the department (for example, ENG) id (int) - the course number (for example, 101) credits (double) - the credits (for example, 3) price (double) - the fee for the course (for example, $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display()...

  • create a programn in C++ that creates a class that represents a manufactured part on a...

    create a programn in C++ that creates a class that represents a manufactured part on a bill of material (BOM). with the following attributes: identifier (The parts identifier as an alpha numeric string), drawing (The AutoCAD drawing file that represents the part), quantity (The number of parts that are required). implement the functions for the Part class in the file Part.cpp. The file main.cpp will only be used for testing purposes, no code should be written in main.cpp. -part.cpp file:...

  • You will create a class to keep student's information: name, student ID, and grade. The program...

    You will create a class to keep student's information: name, student ID, and grade. The program will have the following functionality: - The record is persistent, that is, the whole registry should be saved on file upon exiting the program, and after any major change. - The program should provide the option to create a new entry with a student's name, ID, and grade. - There should be an option to lookup a student from his student ID (this will...

  • Here is the code from the previous three steps: #include <iostream> using namespace std; class Student...

    Here is the code from the previous three steps: #include <iostream> using namespace std; class Student { private: //class variables int ID; string firstName,lastName; public: Student(int ID,string firstName,string lastName) //constructor { this->ID=ID; this->firstName=firstName; this->lastName=lastName; } int getID() //getter method { return ID; } virtual string getType() = 0; //pure virtual function virtual void printInfo() //virtual function to print basic details of a student { cout << "Student type: " << getType() << endl; cout << "Student ID: " << ID...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT