the following code is centered around data collection, filtering, and using the Singleton pattern in Java, which is all part of a mockup "student information management system", with its purpose being making mockup new student accounts. I've been having issues using the software “dbeaver” for making java projects. Please organize the below code into an executable project “simulation.student” and given step by step instruction as to how this was done Address.java public class Address { private String _city; private String _state; private String _streetName; // New private int _streetNumber; // New private int _apartmentNumber; // New public Address(String city, String state, int zip, String streetName, int streetNumber, int apartmentNumber) { setCity(city); setState(state); setZip(zip); setStreetName(streetName); setStreetNumber(streetNumber); setApartmentNumber(apartmentNumber); } public String getCity() { return _city; } public void setCity(String city) { _city = city; } public String getState() { return _state; } public void setState(String state) { _state = state; } public int getZip() { return _zip; } public void setZip(int zip) { _zip = zip; } public String getStreetName() { return _streetName; } public void setStreetName(String streetName) { _streetName = streetName; } public int getStreetNumber() { return _streetNumber; } public void setStreetNumber(int streetNumber) { _streetNumber = streetNumber; } public int getApartmentNumber() { return _apartmentNumber; } public void setApartmentNumber(int apartmentNumber) { _apartmentNumber = apartmentNumber; } }   Student.java   public abstract class Student { private long Id; private String _lastName, _firstName; protected Address _stuAddress; protected double tuition; protected StudentClassification eStudentClass; public Student(String firstName, String lastName, StudentClassification eStudent, Address stuAddress) { setId(); if ((!firstName.equals("")) && (firstName.matches("^[-a-zA-Z\\s]*$"))) { setFirstName(firstName); } else { setFirstName("INVALID FIRST NAME"); } setLastName(lastName); setClassification(eStudent); _stuAddress = stuAddress; } private void setId() { Id = StudentIdGenerator.getNextId(); } public long getId() { return Id; } public String getLastName() { return _lastName; } public void setLastName(String pName) { _lastName = pName; } public String getFirstName() { return _firstName; } public void setFirstName(String pName) { _firstName = pName; } public double getTuition() { return tuition; } public StudentClassification getClassification() { return eStudentClass; } public abstract void setTuition(); @Override public String toString() { StringBuilder studentInfo = new StringBuilder("Name: " + getFirstName() + " " + getLastName() + "\n"); studentInfo.append("ID: " + getId() + " Tuition: " + getTuition() + "\n"); studentInfo.append("Address: " + _stuAddress.getCity() + ", " + _stuAddress.getState()); studentInfo.append(" " + _stuAddress.getZip()); studentInfo.append(" " + _stuAddress.getStreetName() + ", " + _stuAddress.getStreetNumber()); studentInfo.append(", Apt " + _stuAddress.getApartmentNumber()); return studentInfo.toString(); } } StudentDemo3.java import java.util.ArrayList; public class StudentDemo3 { public static void main(String[] args) { ArrayList students = new ArrayList<>(); StringBuilder studentOutput = new StringBuilder(""); // Use the setStartingID() method in 'StudentIdGenerator' Singleton class to start at 500 StudentIdGenerator.setStartingID(500); students.add(new UndergraduateStudent("Harry Muggle", "Potter", StudentClassification.FRESHMAN, new Address("Atlanta", "Georgia", 30305, "Main St", 123, 101))); students.add(new UndergraduateStudent("Diana-Wonder-Woman", "Prince", StudentClassification.JUNIOR, new Address("Washington D.C.", "District of Columbia", 30318, "Broadway Ave", 456, 202))); // Add two GraduateStudent objects to the 'students' collection (ArrayList) students.add(new GraduateStudent("John", "Doe", StudentClassification.MASTERS, new Address("New York", "New York", 10001, "5th Ave", 789, 303))); students.add(new GraduateStudent("Jane", "Smith", StudentClassification.DOCTORATE, new Address("Los Angeles", "California", 90001, "Sunset Blvd", 987, 505))); // Loop to print student information for (Student s : students) { studentOutput.append("\n-----------------------------\n").append(s.toString()); if (s instanceof UndergraduateStudent) { studentOutput.append("\nUndergraduate student of status: ").append(s.getClassification().toString()); } else if (s instanceof GraduateStudent) { studentOutput.append("\nGraduate student of status: ").append(s.getClassification().toString()); } System.out.println(studentOutput.toString() + "\n"); studentOutput.setLength(0); } } }    please run the code such that it has the appropriate expected outcome of ----------------------------- Name: Harry Muggle Potter ID: 500 Tuition: 4000.0 Address: St. Louis, Georgia 30305 Undergraduate student of status: FRESHMAN -----------------------------

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

the following code is centered around data collection, filtering, and using the Singleton pattern in Java, which is all part of a mockup "student information management system", with its purpose being making mockup new student accounts. I've been having issues using the software “dbeaver” for making java projects. Please organize the below code into an executable project “simulation.student” and given step by step instruction as to how this was done

Address.java

public class Address {
private String _city;
private String _state;
private String _streetName; // New
private int _streetNumber; // New
private int _apartmentNumber; // New

public Address(String city, String state, int zip, String streetName, int streetNumber, int apartmentNumber) {
setCity(city);
setState(state);
setZip(zip);
setStreetName(streetName);
setStreetNumber(streetNumber);
setApartmentNumber(apartmentNumber);
}

public String getCity() {
return _city;
}

public void setCity(String city) {
_city = city;
}

public String getState() {
return _state;
}

public void setState(String state) {
_state = state;
}

public int getZip() {
return _zip;
}

public void setZip(int zip) {
_zip = zip;
}

public String getStreetName() {
return _streetName;
}

public void setStreetName(String streetName) {
_streetName = streetName;
}

public int getStreetNumber() {
return _streetNumber;
}

public void setStreetNumber(int streetNumber) {
_streetNumber = streetNumber;
}

public int getApartmentNumber() {
return _apartmentNumber;
}

public void setApartmentNumber(int apartmentNumber) {
_apartmentNumber = apartmentNumber;
}
}

 

Student.java

 

public abstract class Student {
private long Id;
private String _lastName, _firstName;
protected Address _stuAddress;

protected double tuition;
protected StudentClassification eStudentClass;

public Student(String firstName, String lastName, StudentClassification eStudent, Address stuAddress) {
setId();
if ((!firstName.equals("")) && (firstName.matches("^[-a-zA-Z\\s]*$"))) {
setFirstName(firstName);
} else {
setFirstName("INVALID FIRST NAME");
}
setLastName(lastName);
setClassification(eStudent);
_stuAddress = stuAddress;
}

private void setId() {
Id = StudentIdGenerator.getNextId();
}

public long getId() {
return Id;
}

public String getLastName() {
return _lastName;
}

public void setLastName(String pName) {
_lastName = pName;
}

public String getFirstName() {
return _firstName;
}

public void setFirstName(String pName) {
_firstName = pName;
}

public double getTuition() {
return tuition;
}

public StudentClassification getClassification() {
return eStudentClass;
}

public abstract void setTuition();

@Override
public String toString() {
StringBuilder studentInfo = new StringBuilder("Name: " + getFirstName() + " " + getLastName() + "\n");
studentInfo.append("ID: " + getId() + " Tuition: " + getTuition() + "\n");
studentInfo.append("Address: " + _stuAddress.getCity() + ", " + _stuAddress.getState());
studentInfo.append(" " + _stuAddress.getZip());
studentInfo.append(" " + _stuAddress.getStreetName() + ", " + _stuAddress.getStreetNumber());
studentInfo.append(", Apt " + _stuAddress.getApartmentNumber());
return studentInfo.toString();
}
}

StudentDemo3.java

import java.util.ArrayList;

public class StudentDemo3 {
public static void main(String[] args) {
ArrayList<Student> students = new ArrayList<>();
StringBuilder studentOutput = new StringBuilder("");

// Use the setStartingID() method in 'StudentIdGenerator' Singleton class to start at 500
StudentIdGenerator.setStartingID(500);

students.add(new UndergraduateStudent("Harry Muggle", "Potter", StudentClassification.FRESHMAN,
new Address("Atlanta", "Georgia", 30305, "Main St", 123, 101)));
students.add(new UndergraduateStudent("Diana-Wonder-Woman", "Prince", StudentClassification.JUNIOR,
new Address("Washington D.C.", "District of Columbia", 30318, "Broadway Ave", 456, 202)));

// Add two GraduateStudent objects to the 'students' collection (ArrayList)
students.add(new GraduateStudent("John", "Doe", StudentClassification.MASTERS,
new Address("New York", "New York", 10001, "5th Ave", 789, 303)));
students.add(new GraduateStudent("Jane", "Smith", StudentClassification.DOCTORATE,
new Address("Los Angeles", "California", 90001, "Sunset Blvd", 987, 505)));

// Loop to print student information
for (Student s : students) {
studentOutput.append("\n-----------------------------\n").append(s.toString());
if (s instanceof UndergraduateStudent) {
studentOutput.append("\nUndergraduate student of status: ").append(s.getClassification().toString());
} else if (s instanceof GraduateStudent) {
studentOutput.append("\nGraduate student of status: ").append(s.getClassification().toString());
}
System.out.println(studentOutput.toString() + "\n");
studentOutput.setLength(0);
}
}
}

 


 please run the code such that it has the appropriate expected outcome of


-----------------------------
Name: Harry Muggle Potter
ID: 500 Tuition: 4000.0
Address: St. Louis, Georgia 30305
Undergraduate student of status: FRESHMAN
-----------------------------

# UndergraduateStudent.java

```java
public class UndergraduateStudent extends Student {
    public static final double UNDERGRAD_TUITION = 4000;

    public UndergraduateStudent(String fName, String lName, StudentClassification eStudent, Address stuAddress) {
        super(fName, lName, eStudent, stuAddress);
        setTuition();
    }

    @Override
    public void setTuition() {
        tuition = UNDERGRAD_TUITION;
    }
}
```

### Explanation:
This Java code defines a class `UndergraduateStudent`, which inherits from the `Student` class.

- **Attributes and Methods:**
  - `UNDERGRAD_TUITION`: A constant that holds the tuition amount for undergraduate students, set to 4000.
  - Constructor `UndergraduateStudent`: Takes parameters for the student's first name, last name, student classification, and address. It calls the parent class's constructor with these parameters and sets the tuition.
  - `setTuition()`: An overridden method that assigns the tuition value to the undergraduate tuition constant.

This class encapsulates the behavior and attributes specific to an undergraduate student, focusing on maintaining a standardized tuition Fee.
Transcribed Image Text:# UndergraduateStudent.java ```java public class UndergraduateStudent extends Student { public static final double UNDERGRAD_TUITION = 4000; public UndergraduateStudent(String fName, String lName, StudentClassification eStudent, Address stuAddress) { super(fName, lName, eStudent, stuAddress); setTuition(); } @Override public void setTuition() { tuition = UNDERGRAD_TUITION; } } ``` ### Explanation: This Java code defines a class `UndergraduateStudent`, which inherits from the `Student` class. - **Attributes and Methods:** - `UNDERGRAD_TUITION`: A constant that holds the tuition amount for undergraduate students, set to 4000. - Constructor `UndergraduateStudent`: Takes parameters for the student's first name, last name, student classification, and address. It calls the parent class's constructor with these parameters and sets the tuition. - `setTuition()`: An overridden method that assigns the tuition value to the undergraduate tuition constant. This class encapsulates the behavior and attributes specific to an undergraduate student, focusing on maintaining a standardized tuition Fee.
**GraduateStudent.java**

```java
public class GraduateStudent extends Student {
    public static final double GRAD_TUITION = 6000;

    public GraduateStudent(String fName, String lName, StudentClassification eStudent, Address stuAddress) {
        super(fName, lName, eStudent, stuAddress);
        setTuition();
    }

    @Override
    public void setTuition() {
        tuition = GRAD_TUITION;
    }
}
```

### Explanation

- **Class Declaration**: 
  - `GraduateStudent` is a subclass of `Student`.
  
- **Constant**: 
  - `GRAD_TUITION` is a constant with a value of 6000, which represents the tuition for graduate students.
  
- **Constructor**: 
  - Takes four parameters: `fName`, `lName`, `eStudent`, and `stuAddress`.
  - Calls the superclass constructor and then sets the tuition by calling `setTuition()`.

- **Method Override**: 
  - `setTuition()` method overrides a method in the superclass to set the tuition to `GRAD_TUITION`. 

This code is part of an object-oriented program that manages student information, specifically for graduate students.
Transcribed Image Text:**GraduateStudent.java** ```java public class GraduateStudent extends Student { public static final double GRAD_TUITION = 6000; public GraduateStudent(String fName, String lName, StudentClassification eStudent, Address stuAddress) { super(fName, lName, eStudent, stuAddress); setTuition(); } @Override public void setTuition() { tuition = GRAD_TUITION; } } ``` ### Explanation - **Class Declaration**: - `GraduateStudent` is a subclass of `Student`. - **Constant**: - `GRAD_TUITION` is a constant with a value of 6000, which represents the tuition for graduate students. - **Constructor**: - Takes four parameters: `fName`, `lName`, `eStudent`, and `stuAddress`. - Calls the superclass constructor and then sets the tuition by calling `setTuition()`. - **Method Override**: - `setTuition()` method overrides a method in the superclass to set the tuition to `GRAD_TUITION`. This code is part of an object-oriented program that manages student information, specifically for graduate students.
Expert Solution
Step 1: Algorithm :

Algorithm: Student Information Management System

1. Create an empty ArrayList to store student objects.

2. Create a StringBuilder to build the student information output.

3. Set the starting ID for student generation using the StudentIdGenerator Singleton.

4. Create four student objects:
    a. Create an UndergraduateStudent object "Harry Potter" with the following details:
        - Name: Harry Potter
        - Student Classification: FRESHMAN
        - Address: Atlanta, Georgia, 30305, Main St, 123, Apt 101
    b. Create an UndergraduateStudent object "Diana-Wonder-Woman Prince" with the following details:
        - Name: Diana-Wonder-Woman Prince
        - Student Classification: JUNIOR
        - Address: Washington D.C., District of Columbia, 30318, Broadway Ave, 456, Apt 202
    c. Create a GraduateStudent object "John Doe" with the following details:
        - Name: John Doe
        - Student Classification: MASTERS
        - Address: New York, New York, 10001, 5th Ave, 789, Apt 303
    d. Create a GraduateStudent object "Jane Smith" with the following details:
        - Name: Jane Smith
        - Student Classification: DOCTORATE
        - Address: Los Angeles, California, 90001, Sunset Blvd, 987, Apt 505

5. Loop through each student in the ArrayList:
    a. Build student information as follows:
        - Name
        - ID
        - Tuition
        - Address (City, State, Zip, Street, Street Number, Apartment Number)
        - Student Classification (Undergraduate or Graduate)
    b. Print the student information.

6. End the loop.

7. End the program.


steps

Step by step

Solved in 5 steps with 8 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY