The xxx_Student class:– Name - the name consists of the First and Last name separated by a space.– Student Id – a whole number automatically assigned in the student class– Student id numbers start at 100. The numbers are assigned using a static variable in the Student class• Include all instance variables• Getters and setters for instance variables• A static variable used to assign the student id starting at 100• A toString method which returns a String containing the student name and id in the format below:Student: John Jones ID: 101The xxx_Course classA Course has the following information (modify your Course class):– A name– An Array of Students which contains an entry for each Student enrolled in the course (allow for up to 10 students)– An integer variable which indicates the number of students currently enrolled in the course.Write the constructor below which does the following:Course (String name)Sets courseName to nameCreates the students array of size 10Sets number of Students to 0Write the 3 getters+getCourseName() : String+getStudents() : Student []+getNumberOfStudents() : intWrite the 2 setterspublic void addStudent (Student student)public void addStudent (String studentName)Write toStringReturn a String that contains the following information concatenated so that the information prints on separate lines as shown in the sample output:Course: xxxxx Number of Students: xxThe students in the class are:Each of the Student objects in the students array followed by a \n so they print on separate linesWrite a class xxx_TestCourse which willPrompt the user for the name of a Course and create a Course objectIn a loop, until the user enters a q or a Q,Prompt the user to enter student names or Q to endFor each student entered,create a Student object and add it to the Course using the addStudent method of the Course classAt the end of the loop, print the Course object. Its toString method will format the output as shown on the next slide Sample OutputEnter the course nameCPS2231-04Enter the name of a student or Q to quitJonEnter the name of a student or Q to quitMaryEnter the name of a student or Q to quitTomEnter the name of a student or Q to quitqCourse: CPS2231-04 Number of Students: 3The students in the class are:Student: Jon ID: 100Student: Mary ID: 101Student: Tom ID: 102

Question
Asked Oct 9, 2019
137 views

The xxx_Student class:
– Name - the name consists of the First and Last name separated by a space.
– Student Id – a whole number automatically assigned in the student class
– Student id numbers start at 100. The numbers are assigned using a static variable in the Student class
• Include all instance variables
• Getters and setters for instance variables
• A static variable used to assign the student id starting at 100
• A toString method which returns a String containing the student name and id in the format below:
Student: John Jones ID: 101

The xxx_Course class
A Course has the following information (modify your Course class):
– A name
– An Array of Students which contains an entry for each Student enrolled in the course (allow for up to 10 students)
– An integer variable which indicates the number of students currently enrolled in the course.

Write the constructor below which does the following:
Course (String name)
Sets courseName to name
Creates the students array of size 10
Sets number of Students to 0

Write the 3 getters
+getCourseName() : String
+getStudents() : Student []
+getNumberOfStudents() : int

Write the 2 setters
public void addStudent (Student student)
public void addStudent (String studentName)

Write toString
Return a String that contains the following information concatenated so that the information prints on separate lines as shown in the sample output:
Course: xxxxx Number of Students: xx
The students in the class are:
Each of the Student objects in the students array followed by a \n so they print on separate lines

Write a class xxx_TestCourse which will
Prompt the user for the name of a Course and create a Course object
In a loop, until the user enters a q or a Q,
Prompt the user to enter student names or Q to end
For each student entered,
create a Student object and add it to the Course using the addStudent method of the Course class
At the end of the loop, print the Course object. Its toString method will format the output as shown on the next slide

 

Sample Output
Enter the course name
CPS2231-04
Enter the name of a student or Q to quit
Jon
Enter the name of a student or Q to quit
Mary
Enter the name of a student or Q to quit
Tom
Enter the name of a student or Q to quit
q
Course: CPS2231-04 Number of Students: 3
The students in the class are:
Student: Jon ID: 100
Student: Mary ID: 101
Student: Tom ID: 102

check_circle

Expert Answer

Step 1
  • Create all required class, and instance variables required to perform the calculation.
  • Then, in the main method, in for loop create an array of objects and call the requir...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Engineering

Programing

Related Computer Engineering Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Are all nonfunctional requirements equally important?  Why or why not?

A: Justification:“Yes”, All non functional requirements are equally important.

question_answer

Q: I need help with this problem I attatched the sample output Exempt You will be writing a program to ...

A: Program plan:Display the welcome statementGet the average value from the user and check the average ...

question_answer

Q: 1. What is the output of the following code? public class Loopy {public static void main(String[] ar...

A: 1.Explanation for the given java code:In the class "Loopy", variable "x" is declared and initialized...

question_answer

Q: Consider a 4-way set associative cache made up of 64-bit words. The number of words per line is 8 an...

A: Cache size:The cache size can be calculated using the following formula:

question_answer

Q: Consider different risk mitigation strategies for system development programs. What type of strategy...

A: Risk mitigation: Let’s start to discuss about the risk . Risk is a possibility of loss which occurre...

question_answer

Q: What is the difference between the COUNT aggregate function and the SUM aggregatefunction?

A: In database management, an aggregate function is a feature where various row values are grouped toge...

question_answer

Q: this question is from fundamentals of logic. related to boolean algebra. I am unable to decipher the...

A: Click to see the answer

question_answer

Q: In a special case of a permutation cipher, we take a message, M, and write its letters in an s× t ta...

A: Given, message M= ATTA CKAT DAWNsecret key S= (3,4)Encryption:arrange the message in table form(3x4)...

question_answer

Q: Using Java Eclipse do the following program: Design a class named Rectangle to represent a rectangle...

A: Program Instructions:Declare variables width and height.Create a default and parameterized construct...