Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with my java homework. The code will be below. Enter from console the student code, and we get all the information about

I need help with my java homework. The code will be below.

Enter from console the student code, and we get all the information about the student. Enter the code of the course and we get all the information about course. Write and read the information of the enrollments in file using serialized class Enrollment. Add a method in Controller that displays for each course the respective number of the students.

package com.example;

import java.util.ArrayList; import java.util.Date;

public class Controller { private static final String[] studentCode= {"s100","s200","s300"}; private static final String[] studentName= {"student1","student2","student3"}; private static final int[] studentCredit= {20,25,15}; private static final String[] courseCode= {"cs1000","cs2000","cs3000"}; private static final String[] courseName= {"Java","C++","Android"}; private static final int[] courseCredit= {4,4,3}; private static final String[] regStudentCode= {"s100","s100","s200","s200","s300","s300"}; private static final String[] regCourseCode= {"cs1000","cs2000","cs1000","cs2000","cs2000","cs3000"}; private static final String[] regDate= {"2019/1/09","2019/1/10","2019/1/15","2019/1/09","2019/1/10","2019/1/15"}; private ArrayList courses; private ArrayList students; private ArrayList enrollments; public Controller() { courses=new ArrayList(); students=new ArrayList(); enrollments=new ArrayList(); fillLists(); } private void fillLists() { for(int i=0;i Student s=new Student(studentCode[i],studentName[i], studentCredit[i]); students.add(s); } for(int i=0;i Course c=new Course(courseCode[i],courseName[i], courseCredit[i]); courses.add(c); } for(int i=0;i Student sObj=null; Course cObj=null; for(Student s: students) { if(s.getCode().equals(regStudentCode[i])) sObj=s; } for(Course c: courses) { if(c.getCode().equals(regCourseCode[i])) cObj=c; } if(sObj!=null&&cObj!=null) { Enrollment e=new Enrollment(sObj,cObj,new Date(regDate[i])); enrollments.add(e); } } } private void filStudentEnroll() { for(Student s: students) { for (Enrollment e: enrollments) { if(s.getCode().equals(e.getStudent().getCode())) s.setsEnrollments(e); } } } }

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

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions

Question

Solve 3x 2 + 2 = 7x.

Answered: 1 week ago

Question

6. Explain the power of labels.

Answered: 1 week ago

Question

5. Give examples of variations in contextual rules.

Answered: 1 week ago

Question

f. What stereotypes were reinforced in the commercials?

Answered: 1 week ago