the following code is all part of a mockup "student information management system", with its purpose being making mockup new student accounts. 1) combine the code into a small executable project called simulation.student 2) Using dbeaver, Please use the following attached sql commands and make the tables shown below, populated with the appropriate data SCREENSHOT EACH TABLE WITH THE DATA INSERTED INTO IT code: UndergraduateStudent.java //package Lab2; public class UndergraduateStudent extends Student { public static final double UNDERGRAD_TUITION = 4000; public UndergraduateStudent( int pID, String pName, StudentClassification eStudent ) { super( pID, pName, eStudent ); setTuition(); } public void setTuition() { tuition = UNDERGRAD_TUITION; } } StudentDemo2.java import java.util.ArrayList; public class StudentDemo2 { public static void main(String[] args) { ArrayList students = new ArrayList(); students.add( new UndergraduateStudent(111, "Lambert", StudentClassification.FRESHMAN )); students.add( new UndergraduateStudent(122, "Lembeck", StudentClassification.JUNIOR )); students.add( new GraduateStudent(999, "Sadasivuni", StudentClassification.DOCTORATE )); students.add( new GraduateStudent(887,"Kamidi", StudentClassification.MASTERS )); for (Student S : students) { System.out.println( "\nStudent ID: " + S.getId() + ", Last Name: " + S.getLastName() + ", Tuition: " + S.getTuition() + " per year."); if( S instanceof UndergraduateStudent ) { System.out.println( S.getLastName() + " is an Undergraduate of status: " + S.getClassification().toString() ); } else if ( S instanceof GraduateStudent ) { System.out.println( S.getLastName() + " is a Graduate of Status: " + S.getClassification().toString() ); } } } } StudentClassification.java public enum StudentClassification { FRESHMAN, SOPHOMORE, JUNIOR, SENIOR, MASTERS, DOCTORATE; } Student.java public abstract class Student { private int ID; private String lastName; protected double tuition; protected StudentClassification eStudentClass; public Student( int pID, String pName, StudentClassification eStudent ) { setId( pID ); setLastName( pName ); setClassifcation( eStudent ); } public void setId( int idNum ) { ID=idNum; } public void setLastName( String pName ) { lastName = pName; } public int getId() { return ID; } public String getLastName() { return lastName; } public double getTuition() { return tuition; } public void setClassifcation( StudentClassification eStudent ){ eStudentClass = eStudent; } public StudentClassification getClassification( ) { return eStudentClass; } // no concrete code for abstract methods public abstract void setTuition(); } GraduateStudent.java //package Lab2; /* */ public class GraduateStudent extends Student { public static final double GRAD_TUITION = 6000; public GraduateStudent( int pID, String pName, StudentClassification eStudent ) { super( pID, pName, eStudent ); setTuition(); } public void setTuition() { tuition = GRAD_TUITION; } } studentidGenerator.java // This is a Singleton pattern class to use in global scope // it allows a starting number for studentID and a method to get the next ID in // an isolation method to protect from having duplicates public class StudentIdGenerator { private static StudentIdGenerator instance = null; private static long nextId = 0; private StudentIdGenerator() { } public static StudentIdGenerator getInstance( ) { if (instance == null) { instance = new StudentIdGenerator( ); } return instance; } public static long getNextId( ) { return nextId++; } public static void setStartingID( long Id ) { nextId = Id; } }
the following code is all part of a mockup "student
1) combine the code into a small executable project called simulation.student
2) Using dbeaver, Please use the following attached sql commands and make the tables shown below, populated with the appropriate data
SCREENSHOT EACH TABLE WITH THE DATA INSERTED INTO IT
code:
UndergraduateStudent.java
//package Lab2;
public class UndergraduateStudent extends Student
{
public static final double UNDERGRAD_TUITION = 4000;
public UndergraduateStudent( int pID, String pName, StudentClassification eStudent )
{
super( pID, pName, eStudent );
setTuition();
}
public void setTuition()
{
tuition = UNDERGRAD_TUITION;
}
}
StudentDemo2.java
import java.util.ArrayList;
public class StudentDemo2
{
public static void main(String[] args)
{
ArrayList<Student> students = new ArrayList<Student>();
students.add( new UndergraduateStudent(111, "Lambert", StudentClassification.FRESHMAN ));
students.add( new UndergraduateStudent(122, "Lembeck", StudentClassification.JUNIOR ));
students.add( new GraduateStudent(999, "Sadasivuni", StudentClassification.DOCTORATE ));
students.add( new GraduateStudent(887,"Kamidi", StudentClassification.MASTERS ));
for (Student S : students)
{
System.out.println( "\nStudent ID: " +
S.getId() + ", Last Name: " +
S.getLastName() + ", Tuition: " +
S.getTuition() + " per year.");
if( S instanceof UndergraduateStudent )
{
System.out.println( S.getLastName() + " is an Undergraduate of status: " +
S.getClassification().toString() );
}
else if ( S instanceof GraduateStudent )
{
System.out.println( S.getLastName() + " is a Graduate of Status: " +
S.getClassification().toString() );
}
}
}
}
StudentClassification.java
public enum StudentClassification {
FRESHMAN,
SOPHOMORE,
JUNIOR,
SENIOR,
MASTERS,
DOCTORATE;
}
Student.java
public abstract class Student
{
private int ID;
private String lastName;
protected double tuition;
protected StudentClassification eStudentClass;
public Student( int pID, String pName, StudentClassification eStudent )
{
setId( pID );
setLastName( pName );
setClassifcation( eStudent );
}
public void setId( int idNum )
{
ID=idNum;
}
public void setLastName( String pName )
{
lastName = pName;
}
public int getId()
{
return ID;
}
public String getLastName()
{
return lastName;
}
public double getTuition()
{
return tuition;
}
public void setClassifcation( StudentClassification eStudent ){
eStudentClass = eStudent;
}
public StudentClassification getClassification( )
{
return eStudentClass;
}
// no concrete code for abstract methods
public abstract void setTuition();
}
GraduateStudent.java
//package Lab2;
/*
*/
public class GraduateStudent extends Student
{
public static final double GRAD_TUITION = 6000;
public GraduateStudent( int pID, String pName, StudentClassification eStudent )
{
super( pID, pName, eStudent );
setTuition();
}
public void setTuition()
{
tuition = GRAD_TUITION;
}
}
studentidGenerator.java
// This is a Singleton pattern class to use in global scope
// it allows a starting number for studentID and a method to get the next ID in
// an isolation method to protect from having duplicates
public class StudentIdGenerator
{
private static StudentIdGenerator instance = null;
private static long nextId = 0;
private StudentIdGenerator()
{
}
public static StudentIdGenerator getInstance( )
{
if (instance == null)
{
instance = new StudentIdGenerator( );
}
return instance;
}
public static long getNextId( )
{
return nextId++;
}
public static void setStartingID( long Id )
{
nextId = Id;
}
}
Algorithm: Student Information Management System
1. Define the Student class:
- Create a class named "Student" as an abstract class.
- Include instance variables for student ID, last name, tuition, and student classification.
- Define methods for setting and getting ID, last name, tuition, and classification.
- Declare an abstract method "setTuition" to be implemented in subclasses.
2. Define the UndergraduateStudent class:
- Create a subclass named "UndergraduateStudent" that extends the Student class.
- Define a constant for undergraduate tuition.
- Implement the "setTuition" method to set tuition to the undergraduate rate.
3. Define the GraduateStudent class:
- Create another subclass named "GraduateStudent" that extends the Student class.
- Define a constant for graduate tuition.
- Implement the "setTuition" method to set tuition to the graduate rate.
4. Define the StudentClassification enumeration:
- Create an enumeration type "StudentClassification" to represent different student classifications like FRESHMAN, SOPHOMORE, etc.
5. Implement the StudentDemo2 class:
- Create a class named "StudentDemo2" to demonstrate the system.
- Instantiate an ArrayList to store student objects.
- Create and add instances of UndergraduateStudent and GraduateStudent to the ArrayList.
- Iterate through the ArrayList and display student information, including ID, last name, tuition, and classification.
6. Define the StudentIdGenerator class:
- Create a class named "StudentIdGenerator" to generate unique student IDs.
- Implement the Singleton pattern to ensure a single instance of the generator.
- Provide methods to get the next ID and set the starting ID.
7. Create a manifest file:
- Create a manifest file named "MANIFEST.MF" to specify the main class for the JAR file.
8. Compile the code:
- Compile the Java code using the "javac" command, creating class files in a "bin" directory.
9. Create a JAR file:
- Create a JAR file named "StudentSimulation.jar" using the "jar" command, including the compiled classes and the manifest file.
10. Run the program:
- Execute the program by running "java -jar StudentSimulation.jar" in the command line.
11. The program will execute, displaying the student information on the console.
End of Algorithm.
Step by step
Solved in 4 steps with 7 images