Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

318ii) Could you please help me to solve this Java Programming problem? I have the partial solution but could you please solve the rest of

318ii) Could you please help me to solve this Java Programming problem? I have the partial solution but could you please solve the rest of this problem. My partial solution is given at the very bottom. (PLEASE HELP ME ONLY WITH JAVA PROGRAMMING LANGUAGE)

PROBLEM:

"

Youre going to create a simple student information system that can perform add/drop operations. Your project must have 4 classes: A course class, a technical elective course class which is extended from the course class, a student class and a Test class which contains the main method.

Course Class:

Course class should represent any courses. Course objects must be created from the course id. Youll get the course id from the main and course year & semester variables will be assigned according to the id variable. Lets assume were dealing with CMPE 113. Youll read 113 from the main and decide its year and semester. First digit will give information about the courses year. As you may see 113 ( [1]13) is a first grade course and it is a first semester course (11[3]). If the last digit is an odd number that means the course is a first semester course. Decide the courses year and semester by looking at the ids first and last digits. The second digit will be used to determine if a course is a techinal elective or not. If the courses ids second digit is 5 it means that this course is a technical elective. Create the object according to that information (See technical elective class for mor info.)

Course class must have the following variables:

Course name (String)

Course faculty (String)

Course credit (int)

Course id (int)

Course year (int)

Course semester (int)

Prerequisite course (Course)

And have the following methods:

Accessors (getters&setters) for the variables defined above.

A parameterized constructor that takes the name, credit, faculty and id as a parameter. Constructor should assign the year and semester variables according to the information given above.

Youll be given a course table. In that table you can see the prerequisites. If a course has a prerequisite you must assign that to the prerequisite variable.

Override ToString( ) method to print the information about the course. You can print all class variables.

Technical Elective Class:

Technical Elective class represents any techinal electives. If the courses ids second digit is 5, this course will be generated as a technical elective. Technical elective class will be extended from course class. Different from the course class t.e. class must have a thresh hold credit variable. Threshold credit variable will be sent from the main before creating the technical elective object. So check the course id first, decide if its a must or a technical elective course, if its a technical elective ask for its threshold credit variable. This threshod credit variable will be used to determine if a student is eligible for that technical elective or not. T.E courses extra variables are:

Threshold credit (double)

Its functions:

Accessors (getters&setters) for the extra variable defined above.

A parameterized constructor that takes the name, credit, faculty, threshold credit and id as a parameter. Constructor should assign the year and semester variables according to the information given above (look for the course class). Call the super method with the necessary variables.

Override ToString( ) method so that it can print about the course + its threshold credit.

Create a boolean IsEligible( ) method for your technical elective class. This method takes Student object as a parameter and checks if the students GPA is bigger than the threshold credit variable. If its method returns true, if its not method returns false.

Student Class:

Create a class that will represent the Students in a university. Your Student class should have the following variables:

Student name (String)

Student faculty (String)

Student id (int)

Semester count (int)

Credit limit for this semester (int, by default 20)

Students GPA (double)

Passed Courses (Course array)

Semester Courses (Course array)

Passed Courses represents the courses passed by the student. Youre going to use that array in order to decide if a student is eligible for a specific lesson. See Add( ) method for more information.

And have the following methods:

Accessors (getters&setters) for the variables defined above.

A parameterized constructor that takes name, faculty, id, semester count, GPA as a parameter. Your constructor should assign 20 to the credit limit by default. But if the students GPA is higher than 2.5 credit limit should be assigned as 30.

Create a method named Add( ). This method will be used to add courses to the semester courses array if the student is eligible for the specified course. This method will take a course object and after that the method will search if the sent course has a prerequisite, if the sent course has a prerequisite, method will iterate through the passed courses array, if the prerequisite is passed by the student course will be added to the Semester courses list, if not give a proper error. You should also check for the credit limit of a student. If the credit limit is reached Adding operation should give a proper message. Also check if the sent course is a technical elective or not. If it is, check if the IsEligible( ) method to decide if a students GPA is enough to take that elective course. You can check it by using instanceof keyword or by looking at the second digit of the courses id.

Override ToString( ) method in order to print information about the student objects variables. This method should also print the semester courses ids. Passed courses ids are not necessary.

Create the given courses (or technical electives) in your main method as objects. Assign if the coures has a prerequisite. Create a few student objects and assign some courses to their passed courses arrays (you can create a method for this operation or you can add them manually). Show that the Add( ) method gives proper outputs for different situations. Print one of the students semester courses informations (call courses ToString( ) methods in the array).You must test the following cases:

Create a course without a prerequisite:

A student object tries to add this course and adds succesfully.

A student object cant add this course because he/she reaches the credit limit.

Create a course (and a technical elective) with a prerequisite:

A student object tries to add this course and adds succesfully because he/she passed the prerequisite before.

A student object tries to add this course and cant add it succesfully because he/she couldnt passed the prerequisite.

A student object tries to add this technical elective course and adds succesfully because he/she passed the prerequisite and his/hers GPA is enough.

A student object tries to add this technical elective course and cant add it succesfully because he/she couldnt passed the prerequisite or his/hers GPA is not high enough.

image text in transcribed

Use this table as to get courses informations. You can create different courses if you want to but you must show all the cases defined above. Good Luck.

Output:

//Create Courses here.

Student canan created.

Student ahmet created.

//Add some passed courses to students passed courses arrays.

Canan couldnt take Cmpe114 because she didnt pass the prerequisite (cmpe113) //You can print the prerequisite if you want to.

Canan added cmpe134 succesfully.

Ahmet added Cmpe114 succesfully because he passed the prerequisite (cmpe114)//you can print the prerequisite if you want to.

"

My incomplete solution is given below:

Course.java ----------------- package chegg.student; public class Course { private String name; private String faculty; private int credit; private int id; private int year; private int semester; private Course Prerequisite; public Course(String name, String faculty, int credit, int id) { super(); this.name = name; this.faculty = faculty; this.credit = credit; this.id = id; this.year = id / 100; this.semester = (id % 10) % 10; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getFaculty() { return faculty; } public void setFaculty(String faculty) { this.faculty = faculty; } public int getCredit() { return credit; } public void setCredit(int credit) { this.credit = credit; } public int getId() { return id; } public void setId(int id) { this.id = id; } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public int getSemester() { return semester; } public void setSemester(int semester) { this.semester = semester; } public Course getPrerequisite() { return Prerequisite; } public void setPrerequisite(Course prerequisite) { Prerequisite = prerequisite; } @Override public String toString() { return "Course [name=" + name + ", faculty=" + faculty + ", credit=" + credit + ", id=" + id + ", year=" + year + ", semester=" + semester + ", Prerequisite=" + Prerequisite + "]"; } } TechnicalElectivecourse.java ------------------------------------- package chegg.student; public class TechnicalElectiveCourse extends Course { private double thresholdCredit; public TechnicalElectiveCourse(String name, String faculty, int credit, int id, double thresholdCredit) { super(name, faculty, credit, id); this.thresholdCredit = thresholdCredit; } public double getThresholdCredit() { return thresholdCredit; } public void setThresholdCredit(double thresholdCredit) { this.thresholdCredit = thresholdCredit; } @Override public String toString() { return "TechnicalElectiveCourse [" + super.toString() + ",thresholdCredit=" + thresholdCredit + "]"; } public boolean IsEligible(Student student) { boolean flag = false; if (student != null && student.getGPA() > this.thresholdCredit) { flag = true; } else { flag = false; } return flag; } } Student.java ----------------- package chegg.student; public class Student { private String name; private String faculty; private int id; private int semesterCount; private int creditLimit; private double GPA; private Course[] passedCourses; private Course[] semesterCourses; public Student(String name, String faculty, int id, int semesterCount, double gPA) { super(); this.name = name; this.faculty = faculty; this.id = id; this.semesterCount = semesterCount; this.GPA = gPA; if(this.GPA > 2.5){ this.creditLimit = 30; }else{ this.creditLimit = 20; } this.passedCourses = passedCourses; this.semesterCourses = semesterCourses; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getFaculty() { return faculty; } public void setFaculty(String faculty) { this.faculty = faculty; } public int getId() { return id; } public void setId(int id) { this.id = id; } public int getSemesterCount() { return semesterCount; } public void setSemesterCount(int semesterCount) { this.semesterCount = semesterCount; } public int getCreditLimit() { return creditLimit; } public void setCreditLimit(int creditLimit) { this.creditLimit = creditLimit; } public double getGPA() { return GPA; } public void setGPA(double gPA) { GPA = gPA; } public Course[] getPassedCourses() { return passedCourses; } public void setPassedCourses(Course[] passedCourses) { this.passedCourses = passedCourses; } public Course[] getSemesterCourses() { return semesterCourses; } public void setSemesterCourses(Course[] semesterCourses) { this.semesterCourses = semesterCourses; } public void add(Course course){ } } Main.java -------------- package chegg.student; import java.util.ArrayList; import java.util.List; public class Main { public static List courseDetails = new ArrayList(); static { courseDetails.add("113,NA,NA"); courseDetails.add("114,113,NA"); courseDetails.add("225,114,NA"); courseDetails.add("226,NA,NA"); courseDetails.add("134,NA,NA"); courseDetails.add("109,NA,NA"); courseDetails.add("458,225,3.0"); courseDetails.add("312,NA,NA"); courseDetails.add("318,NA,NA"); courseDetails.add("334,114,NA"); } public static void main(String[] args) { // Create a course without a prerequisite Course course = null; String[] courseInfo = courseDetails.get(0).split(","); Student student = new Student("name1", "faculty", 1, 6, 2.5); if (courseInfo[1] != null) { String flag = courseInfo[1]; if ("5".equals("flag")) { course = new TechnicalElectiveCourse("Course1", "faculty1", 20, Integer.parseInt(courseInfo[0]), 0.0); } else { course = new Course("Course1", "faculty1", 20, Integer.parseInt(courseInfo[0])); } } System.out.println(course.toString()); // Create a course (and a technical elective) with a prerequisite Course courseHasPrerequisite = null; String[] courseInfo2 = courseDetails.get(1).split(","); Student student2 = new Student("name2", "faculty2", 2, 5, 2.5); if (courseInfo2[1] != null) { String flag = courseInfo2[1]; int seconddigit = Integer.parseInt(flag)/10; seconddigit = seconddigit/10; if ("5".equals(""+seconddigit)) { courseHasPrerequisite = new TechnicalElectiveCourse("Course2", "faculty2", 20, Integer.parseInt(courseInfo2[0]), 0.0); } else { courseHasPrerequisite = new Course("Course2", "faculty2", 20, Integer.parseInt(courseInfo2[0])); } } } public String findPrerequisite(String[] courseId) { for (String courseInfo : Main.courseDetails) { if (courseId[1].equals(courseInfo.split(",")[0])) { return courseInfo; } } return null; } public List processPrerequisite(int courseRecordIndx) { List list = new ArrayList(); boolean ifPrerequisiteFound = true; String coursePrerequisite = Main.courseDetails.get(courseRecordIndx); while (ifPrerequisiteFound) { coursePrerequisite = findPrerequisite(coursePrerequisite.split(",")); if ("NA".equals(coursePrerequisite)) { break; } else { list.add(coursePrerequisite); } } return list; } }

--------------------------------------------------------------------------------------------------------------------------------------------------- Description

1. constructed all the classes and thier methods.

2. With the above given code, we can create course, student class object

3. main.java class does have main method to create the course and student class object.

4. Could you please solve the rest of the problem?

----------------------------------------------------------------------------------------------------

sincerely..

Course ID: GPA limit Prerequisite ID: 113 113 114 225 114 226 134 109 458 225 3.0 312 318 334 114 341

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions