Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java code Exercise: 1-Students and Teacher System Suppose that you are required to model students and teachers in one application. Design a class named Person
java code
Exercise: 1-Students and Teacher System Suppose that you are required to model students and teachers in one application. Design a class named Person and its two subclasses named Student and Teacher: A person has a name and address. A student has a number of courses and their grades. A teacher has a number of courses taught currently. - For students, you need to maintain the courses taken and their respective grades; add a course with grade, print all courses taken and print the average grade. A student takes no more than 30 courses for the entire program. - For teachers, you need to maintain the courses taught currently, able to add or remove a course taught and print all courses. A teacher can teach no more than 5 courses concurrently. 1. Instance variables: - numCourses: number of courses taken so far. - courses: course codes. - grades: grade for the corresponding course codes. - private static final int MAX_COURSES =30 : maximum number of courses. 2. Constructor - should construct a new student object with name, address as String. Initializing the courses and grades variables with the value of MAX_COURSES. 3. Methods: - toString:@Override, printing the student Information. - addCourseGrade: Add a course and its grade - No validation in this method. - printGrades: Print all courses taken and their grade. - getAverageGrade: Compute the average grade. 2. Constructor - should construct a new teacher object with name, address as String. Initializing number of courses to Zero and courses variables with the value of MAX_COURSES. 3. Methods: - toString: Override, printing the teacher Information. - addCourse: Return false if duplicate course to be added. - removeCourse: Return false if the course does not exist in the courses list. - printCourses: Print the list of courses. Application Class - Display a menu to the user to choose whether he/she is student or teacher. - If the user choice is (student), allow him to choose from the list: 1. new student 2. add course 3. print grades 4. get the average 5. exit - If the user choice is (teacher), allow him to choose from the list: 1. new teacher 2. add course 3. remove course 4. print all courses 5. exit Notes: - Your program should deal with the duplication that means the teacher cannot add two courses with same name and cannot delete a course that has been deleted. - Try to add courses and print in the screen a message telling the user that it has been added. Otherwise, give message to tell that it cannot be added. - Try to remove courses and print in the screen a message telling the user that it has been deleted. Otherwise, give message to tell that it cannot be deleted. Welcome to Collage System 1- Teacher Subsystem 2- Student Subsystem 3- Exit Your Choice: 1 *** Welcome to Teacher Sub-system 1- add your personal information 2- add new course 3- remove a course 4- Print all courses 5- Exit Your Choice: 1 Please enter teacher's name:Ahmad Alrashed Please enter teacher's address:Alrakkah, Eastern province, SA Teacher: Ahmad Alrashed (Alrakkah, Eastern province, SA) *** Welcome to Teacher Sub-system *** 1 - add your personal information 2- add new course 3- remove a course 4- Print all courses 5- Exit Your Choice: 2 Please enter the course name: cs311 cs311 added *** Welcome to Teacher Sub-system 1- add your personal information 2- add new course 3- remove a course 4- Print all courses 5- Exit Your Choice: 3 Please enter the course name : cs 312 cs312 can not be removed Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started