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.io.Serializable;
import java.util.Date;
public class Enrollment implements Serializable {
private Student student;
private Course course;
private Date registration;
public Enrollment(Student student, Course course, Date
registration) {
super();
this.student = student;
this.course = course;
this.registration =
registration;
}
public Student getStudent() {
return student;
}
public Course getCourse() {
return course;
}
public Date getRegistration() {
return registration;
}
public String toString() {
return "[enrollment
"+student.getCode()+" "+
course.getCode()+" "+registration+"]";
}
}
package HomeworkLib.sorting;
public class Student {
private String student_name;
private int student_id;
public Student(String student_name , int
student_id){
this.student_name =
student_name;
this.student_id = student_id;
}
public synchronized String getStudent_name() {
return student_name;
}
public synchronized void setStudent_name(String
student_name) {
this.student_name =
student_name;
}
public synchronized int getStudent_id() {
return student_id;
}
public synchronized void setStudent_id(int student_id)
{
this.student_id = student_id;
}
}
package HomeworkLib.sorting;
public class Course {
public String Course_name;
public int Course_id;
public int no_of_students;
public Course(String Course_name, int Course_id , int
no_of_students)
{
this.Course_name =
Course_name;
this.Course_id = Course_id;
this.no_of_students =
no_of_students;
}
public synchronized String getCourse_name() {
return Course_name;
}
public synchronized void setCourse_name(String
course_name) {
Course_name = course_name;
}
public synchronized int getCourse_id() {
return Course_id;
}
public synchronized void setCourse_id(int
course_id) {
Course_id = course_id;
}
public synchronized int getNo_of_students() {
return no_of_students;
}
public synchronized void setNo_of_students(int
no_of_students) {
this.no_of_students =
no_of_students;
}
}
package HomeworkLib.sorting;
import java.io.Serializable;
import java.util.Date;
public class Enrollment implements Serializable {
private Student student;
private Course course;
private Date registration;
public Enrollment(Student s1,Course c1, Date
registration)
{
this.student = s1;
this.course = c1;
this.registration =
registration;
}
public synchronized Student getStudent() {
return student;
}
public synchronized void setStudent(Student
student) {
this.student = student;
}
public synchronized Course getCourse() {
return course;
}
public synchronized void setCourse(Course course)
{
this.course = course;
}
public synchronized Date getRegistration() {
return registration;
}
public synchronized void setRegistration(Date
registration) {
this.registration =
registration;
}
}
package HomeworkLib.sorting;
import java.util.Date;
import java.util.Scanner;
public class Mainclass {
public static void main(String[] args) {
Scanner scan = new
Scanner(System.in);
Student s1[] = new
Student[10];
Course c1[] = new Course[10];
Enrollment e1[] = new
Enrollment[10];
s1[0] = new Student("Test1",
123);
c1[0] = new Course("JAva",
1234,10);
e1[0] = new Enrollment(s1[0],
c1[0], new Date());
s1[1] = new Student("Test12",
1234);
c1[1] = new Course("C++",
12,15);
e1[1] = new Enrollment(s1[1],
c1[1], new Date());
System.out.println("Enter Student
code");
int a = scan.nextInt();
for (int i = 0; i < e1.length;
i++) {
if(e1[i].getStudent().getStudent_id() == a)
{
System.out.println(e1[i].getStudent().getStudent_name());
break;
}
}
System.out.println("Enter Course
code");
int code = scan.nextInt();
for (int i = 0; i < e1.length;
i++) {
if(e1[i].getCourse().getCourse_id() == code)
{
System.out.println(e1[i].getCourse().getCourse_name());
System.out.println(e1[i].getCourse().getNo_of_students());
break;
}
}
}
}
I need help with my java homework. The code will be below. Enter from console the...
this is for java programming Please Use Comments I am not 100% sure if my code needs work, this code is for the geometric if you feel like you need to edit it please do :) Problem Description: Modify the GeometricObject class to implement the Comparable interface and define a static max method in the GeometricObject class for finding the larger (in area) of two GeometricObject objects. Draw the UML and implement the new GeometricObject class and its two subclasses...
Analyze the code to determine what the code does, how the data is structured, and why it is the appropriate data structure (i.e. linked list, stack or queue). Note that these are examples of classes and methods and do not include the "main" or "test" code needed to execute. When you are done with your analysis, add a header describing the purpose of the program (include a description of each class and method), the results of your analysis, and add...
******Java Programming Hi guys, I really need you help. I created a code for my java course, but it keep giving me error messages. Majority of my code is fine but some keep display error on my console. I was hoping someone could pin points the problem. .There are three classes with the testCenter class being the main class. In the following is the assignment, and the bottom is my code. Please help! Assignment: Concepts: GUI User Design Graphics Deployment...
I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student { private String firstName; private String lastName; private String id; private boolean tuitionPaid; public Student(String firstName, String lastName, String id, boolean tuitionPaid) { this.firstName=firstName; this.lastName=lastName; this.id=id; this.tuitionPaid=tuitionPaid; } ...
I need help with adding comments to my code and I need a uml diagram for it. PLs help.... Zipcodeproject.java package zipcodesproject; import java.util.Scanner; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Zipcodesproject { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); BufferedReader reader; int code; String state,town; ziplist listOFCodes=new ziplist(); try { reader = new BufferedReader(new FileReader("C:UsersJayDesktopzipcodes.txt")); String line = reader.readLine(); while (line != null) { code=Integer.parseInt(line); line =...
How to solve and code the following requirements (below) using the JAVA program? 1. Modify the FoodProduct Class to implement Edible, add the @Overrride before any methods that were there (get/set methods) that are also in the Edible interface. 2. Modify the CleaningProduct Class to implement Chemical, add the @Overrride before any methods that were there (get/set methods) that are also in the Chemical interface. 3. Create main class to read products from a file, instantiate them, load them into...
java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and short by name, course, instructor, and location. ///main public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Student>students = new ArrayList<>(); int choice; while(true) { displayMenu(); choice = in.nextInt(); switch(choice) { case 1: in.nextLine(); System.out.println("Enter Student Name"); String name...
I need help with my IM (instant messaging) java program, I created the Server, Client, and Message class. I somehow can't get both the server and client to message to each other. I am at a roadblock. Here is the question below. Create an IM (instant messaging) java program so that client and server communicate via serialized objects (e.g. of type Message). Each Message object encapsulates the name of the sender and the response typed by the sender. You may...
For the code below write a public static main() method in class Student that: - creates an ArrayList<Student> object called students - adds 4 new Student objects to the students list, with some made up names and dates - sort the students list by name and display the sorted collection to System.out. use function getCompByName() - sort the students list by enrollment date and display the sorted collection to System.out. use function getCompByDate() import java.util.Comparator; import java.util.Date; public...
Course,java
import java.util.ArrayList;
import java.util.Arrays;
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author fenghui
*/
public class Course {
private String cName;
private ArrayList<Subject>
cores;
private ArrayList<Major>
majors;
private ArrayList<Subject>
electives;
private int cCredit;
public Course(String n, int cc){
cName = n;
cCredit =
cc;
cores = new
ArrayList<Subject>(0);
majors =...