PART I:
Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes:
(1) student ID: protected, an integer of 10 digits
(2) student name: protected
(3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students)
(4) student major: protected (e.g.: Business, Computer Sciences, Engineering)
Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()).
PART II:
Create a Java class named “Undergraduate” in the same package, i.e. STUDENTS, that extends the above class Student. Class Undergraduate has its own one attribute:
undergradLevel: private, a String, to indicate the student level: freshman, sophomore, junior, or senior
Class Undergraduate declaration provides:
a default constructor,
another constructor that accepts 4 parameters: student ID, student full name, major, and undergraduate level
get-method and set-method of its own attribute
a method to return the priority code to register classes (return 1 if senior, 2 if junior, and so on)
a method (displayStudentData()) that implements the abstract method of the same name of the super class and prints out information of a student in a format like the following sample (all in one line):
Student ID: 1234567890; John Smith; senior undergraduate; Business
PART III:
Create a Java class named “Graduate” in the same package, i.e. STUDENTS, that extends the above abstract class Student. This class has one attribute:
isTaRa: private, a boolean, to indicate whether the student is a TA (Teaching Assistant) or RA (Research Assistant)
Class Graduate declaration provides:
a default constructor,
another constructor that accepts 4 parameters: student ID, student full name, major, and a boolean parameter to indicate whether the student is a TA or a RA.
get-method and set-method of its own attribute
a method (displayFigureData()) that implements the abstract method of the same name of the superclass Student and prints out information of the student in a format like the following sample (all in one line):
If a graduate student is not a TA/RA:
Student ID: 1234567890; John Smith; graduate; Information Technology and Management
If a graduate student is a TA/RA:
Student ID: 1234567890; John Smith; graduate; TA; Information Technology and Management
PART IV:
Write a Java program that can get data of a student and print out the data. The student can be either an undergraduate or a graduate. First, the program reads an input of a numeric code that identifies which course work level of student that the user wants to work with.
The values of course work level code are:
1 for undergraduate
2 for graduate
The input of the numeric code must be verified to be sure that it is valid, i.e. can only be either 1 or 2.
For the undergraduate, then the user enters the following pieces of student data from the console:
Student ID
Student full name (first name first)
Student's major
Student's undergraduate level
For the graduate, the user enters the following pieces of student data from the console:
Student ID
Student full name (first name first)
Student's major
Student's status of being aTA/RA: enter 1 for YES; enter 0 for NO
For the input verification:
The input of student ID should be verified that it is not negative or 0.
The input of the full name and major should be verified that they are not empty string.
The input of the undergraduate level should be verified that it can only be "freshman", "sophomore", "junior", or "senior".
The input of the status of being aTA/RA should be verified that it can only be 0 or 1.
The Java program is another Java class named “StudentDisplayer” in the same package, i.e. STUDENTS. To provide a solution to the problem, it is expected that inheritance and polymorphism are used in the coding.
IMPORTANT NOTES:
The following Notepad files are expected to be submitted as the solution to Problem 1:
Student.txt
Undergraduate.txt
Graduate.txt
StudentDisplayer.txt
//Code Image
//Sample output
//Student,txt
Student Details
Student ID = 10
Student full name (first name first) = Mark Waugh
Students Major = Computer Scienes
//Graduate.txt
Default constructor of the Graduate
Student Details
Student ID = 10
Student full name (first name first) = Mark Waugh
Students Major = Computer Scienes
//UnderGraduate.txt
Default constructor of the Undergradaute
Student Details
Student ID = 20
Student full name (first name first) = Michel Clark
Students Major = Business
Students Undergraduatelevel = 1
Enter Student Details
//StudentDisplayer.txt
Enter Student ID
1234567890
Enter Student name
JohnSmith
Enter Student Major
senior
Enter Student Undergraduatelevel
Bussiness
Enter Student's status of being aTA/RA
true
Student Details
Student ID = 1234567890
Student full name (first name first) =JohnSmith
Students Major = Bussiness
Students Undergraduatelevel = junior
//Code to copy
//Student.java
package STUDENTS;
/*Abstract class Student */
public abstract class Student {
/* Declare studentID,studentGroupcode type of integer
*/
/* Declare studentName,studentMajor type of String
*/
protected int studentID;
protected String studentName;
protected int studentGroupcode;
protected String studentMajor;
/*getter and setter methods */
public int getStudentID() {
return studentID;
}
public void setStudentID(int studentID) {
this.studentID = studentID;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName =
studentName;
}
public int getStudentGroupcode() {
return studentGroupcode;
}
public void setStudentGroupcode(int studentGroupcode)
{
this.studentGroupcode =
studentGroupcode;
}
public String getStudentMajor() {
return studentMajor;
}
public void setStudentMajor(String studentMajor)
{
this.studentMajor =
studentMajor;
}
/*abstract methods of displayStudentData and
displayFigureData */
abstract void displayStudentData();
abstract void displayFigureData();
}
//Undergraduate.java
package STUDENTS;
import java.util.*;
/*Undergraduate Class */
public class Undergraduate extends Student{
/*Declare undergradeLevel with type of string */
private String undergradeLevel;
/*Default constructor */
public Undergraduate(){
System.out.println("\n Default
constructor of the Undergradaute ");
}
/* setter and getter methods */
public String getUndergradeLevel() {
return undergradeLevel;
}
public void setUndergradeLevel(String
undergradeLevel) {
this.undergradeLevel =
undergradeLevel;
}
/* parameterized constructor */
public Undergraduate(int studentID,String
studentName,String undergradeLevel,String studentMajor){
this.studentID = studentID;
this.studentName =
studentName;
this.undergradeLevel =
undergradeLevel;
this.studentMajor =
studentMajor;
}
/*Implementation of the priority code */
public void priorityCode(){
if(this.studentGroupcode ==
1){
}
}
public void displayFigureData(){
}
/*Implementation of the displayStudentData */
public void displayStudentData(){
System.out.println("Student
ID:"+studentID);
System.out.println("StudentName:"+studentName);
System.out.println("StudentGroupCode"+studentGroupcode);
System.out.println("studentMajor"+studentMajor);
}
}
//Graduate,java
package STUDENTS;
import java.util.*;
public class Graduate extends Student{
@Override
void displayStudentData() {
// TODO Auto-generated method
stub
}
/*Declare isTaRa type of boolean */
private boolean isTaRa;
/*Default Constructor */
public Graduate() {
// TODO Auto-generated constructor
stub
System.out.println("\n Default
constructor of the Graduate ");
}
/*Parameterized constructor */
Graduate(int studentID,String studentName,int
studentGroupcode,String studentMajor){
this.studentID = studentID;
this.studentName =
studentName;
this.studentGroupcode =
studentGroupcode;
this.studentMajor =
studentMajor;
}
/*Implementation of isTaRa method */
public boolean isTaRa() {
return isTaRa;
}
/*setter method */
public void setTaRa(boolean isTaRa) {
this.isTaRa = isTaRa;
}
/*Implementation of displayFigureData method */
public void displayFigureData(){
if(!isTaRa()){
System.out.println("Student
ID:"+studentID+studentName+studentGroupcode+studentMajor);
}else{
System.out.println("Student
ID:"+studentID+studentName+isTaRa+studentGroupcode+studentMajor);
}
}
}
//StudentDisplayer.java
package STUDENTS;
import java.util.*;
import java.util.Scanner;
/*Declaration of the StudentDisplayer class */
public class StudentDisplayer {
public static void main(String[] args){
/*Create an object for the Graduate
class with
* default constructor
*/
Graduate grObject = new
Graduate();
/*Create an object for the Graduate
class with
* parameterized constructor
*/
Graduate grObject1 = new
Graduate(10,"Mark Waugh",1,"Computer Scienes");
/*Display Statement */
System.out.println("\n Student
Details ");
System.out.println("\n Student ID =
"+grObject1.getStudentID());
System.out.println("\n Student full
name (first name first) = "+grObject1.getStudentName());
System.out.println("\n Students
Major = "+grObject1.getStudentMajor());
/*Create an object for the
Undergraduate class with
* default constructor
*/
Undergraduate UgObject = new
Undergraduate();
/*Create an object for the
Undergraduate class with
* parameterized constructor
*/
Undergraduate UgObject1 = new
Undergraduate(20,"Michel Clark","1","Business");
/*Display Statement */
System.out.println("\n Student
Details ");
System.out.println("\n Student ID =
"+UgObject1.getStudentID());
System.out.println("\n Student full
name (first name first) = "+UgObject1.getStudentName());
System.out.println("\n Students
Major = "+UgObject1.getStudentMajor());
System.out.println("\n Students
Undergraduatelevel = "+UgObject1.getUndergradeLevel());
UgObject1.setUndergradeLevel("junior");
UgObject1.setStudentGroupcode(1);
Scanner sc = new
Scanner(System.in);
System.out.println("\n Enter
Student Details ");
System.out.println("\n Enter
Student ID");
int studentID = sc.nextInt();
UgObject1.setStudentID(studentID);
System.out.println("\n Enter
Student name");
String studentName =
sc.next();
UgObject1.setStudentName(studentName);
System.out.println("\n Enter
Student Major");
String studentMajor =
sc.next();
UgObject1.setStudentMajor(studentMajor);
System.out.println("\n Enter
Student Undergraduatelevel");
String undergradeLevel =
sc.next();
UgObject1.setStudentMajor(undergradeLevel);
System.out.println("\n Enter
Student's status of being aTA/RA");
String isTaRa = sc.next();
grObject1.setTaRa(true);
/*Display Statement */
System.out.println("\n Student
Details ");
System.out.println("\n Student ID =
"+UgObject1.getStudentID());
System.out.println("\n Student full
name (first name first) ="+UgObject1.getStudentName());
System.out.println("\n Students
Major = "+UgObject1.getStudentMajor());
System.out.println("\n Students
Undergraduatelevel = "+UgObject1.getUndergradeLevel());
}
}
//Student.txt
//Student.java
package STUDENTS;
/*Abstract class Student */
public abstract class Student {
/* Declare studentID,studentGroupcode type of integer
*/
/* Declare studentName,studentMajor type of String
*/
protected int studentID;
protected String studentName;
protected int studentGroupcode;
protected String studentMajor;
/*getter and setter methods */
public int getStudentID() {
return studentID;
}
public void setStudentID(int studentID) {
this.studentID = studentID;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName =
studentName;
}
public int getStudentGroupcode() {
return studentGroupcode;
}
public void setStudentGroupcode(int studentGroupcode)
{
this.studentGroupcode =
studentGroupcode;
}
public String getStudentMajor() {
return studentMajor;
}
public void setStudentMajor(String studentMajor)
{
this.studentMajor =
studentMajor;
}
/*abstract methods of displayStudentData and
displayFigureData */
abstract void displayStudentData();
abstract void displayFigureData();
}
//Graduate.txt
//Graduate,java
package STUDENTS;
import java.util.*;
public class Graduate extends Student{
@Override
void displayStudentData() {
// TODO Auto-generated method
stub
}
/*Declare isTaRa type of boolean */
private boolean isTaRa;
/*Default Constructor */
public Graduate() {
// TODO Auto-generated constructor
stub
System.out.println("\n Default
constructor of the Graduate ");
}
/*Parameterized constructor */
Graduate(int studentID,String studentName,int
studentGroupcode,String studentMajor){
this.studentID = studentID;
this.studentName =
studentName;
this.studentGroupcode =
studentGroupcode;
this.studentMajor =
studentMajor;
}
/*Implementation of isTaRa method */
public boolean isTaRa() {
return isTaRa;
}
/*setter method */
public void setTaRa(boolean isTaRa) {
this.isTaRa = isTaRa;
}
/*Implementation of displayFigureData method */
public void displayFigureData(){
if(!isTaRa()){
System.out.println("Student
ID:"+studentID+studentName+studentGroupcode+studentMajor);
}else{
System.out.println("Student
ID:"+studentID+studentName+isTaRa+studentGroupcode+studentMajor);
}
}
}
//Undergraduate.txt
//Undergraduate.java
package STUDENTS;
import java.util.*;
/*Undergraduate Class */
public class Undergraduate extends Student{
/*Declare undergradeLevel with type of string */
private String undergradeLevel;
/*Default constructor */
public Undergraduate(){
System.out.println("\n Default
constructor of the Undergradaute ");
}
/* setter and getter methods */
public String getUndergradeLevel() {
return undergradeLevel;
}
public void setUndergradeLevel(String
undergradeLevel) {
this.undergradeLevel =
undergradeLevel;
}
/* parameterized constructor */
public Undergraduate(int studentID,String
studentName,String undergradeLevel,String studentMajor){
this.studentID = studentID;
this.studentName =
studentName;
this.undergradeLevel =
undergradeLevel;
this.studentMajor =
studentMajor;
}
/*Implementation of the priority code */
public void priorityCode(){
if(this.studentGroupcode ==
1){
}
}
public void displayFigureData(){
}
/*Implementation of the displayStudentData */
public void displayStudentData(){
System.out.println("Student
ID:"+studentID);
System.out.println("StudentName:"+studentName);
System.out.println("StudentGroupCode"+studentGroupcode);
System.out.println("studentMajor"+studentMajor);
}
}
//StudentDisplayer.txt
//StudentDisplayer.java
package STUDENTS;
import java.util.*;
import java.util.Scanner;
/*Declaration of the StudentDisplayer class */
public class StudentDisplayer {
public static void main(String[] args){
/*Create an object for the Graduate
class with
* default constructor
*/
Graduate grObject = new
Graduate();
/*Create an object for the Graduate
class with
* parameterized constructor
*/
Graduate grObject1 = new
Graduate(10,"Mark Waugh",1,"Computer Scienes");
/*Display Statement */
System.out.println("\n Student
Details ");
System.out.println("\n Student ID =
"+grObject1.getStudentID());
System.out.println("\n Student full
name (first name first) = "+grObject1.getStudentName());
System.out.println("\n Students
Major = "+grObject1.getStudentMajor());
/*Create an object for the
Undergraduate class with
* default constructor
*/
Undergraduate UgObject = new
Undergraduate();
/*Create an object for the
Undergraduate class with
* parameterized constructor
*/
Undergraduate UgObject1 = new
Undergraduate(20,"Michel Clark","1","Business");
/*Display Statement */
System.out.println("\n Student
Details ");
System.out.println("\n Student ID =
"+UgObject1.getStudentID());
System.out.println("\n Student full
name (first name first) = "+UgObject1.getStudentName());
System.out.println("\n Students
Major = "+UgObject1.getStudentMajor());
System.out.println("\n Students
Undergraduatelevel = "+UgObject1.getUndergradeLevel());
UgObject1.setUndergradeLevel("junior");
UgObject1.setStudentGroupcode(1);
Scanner sc = new
Scanner(System.in);
System.out.println("\n Enter
Student Details ");
System.out.println("\n Enter
Student ID");
int studentID = sc.nextInt();
UgObject1.setStudentID(studentID);
System.out.println("\n Enter
Student name");
String studentName =
sc.next();
UgObject1.setStudentName(studentName);
System.out.println("\n Enter
Student Major");
String studentMajor =
sc.next();
UgObject1.setStudentMajor(studentMajor);
System.out.println("\n Enter
Student Undergraduatelevel");
String undergradeLevel =
sc.next();
UgObject1.setStudentMajor(undergradeLevel);
System.out.println("\n Enter
Student's status of being aTA/RA");
String isTaRa = sc.next();
grObject1.setTaRa(true);
/*Display Statement */
System.out.println("\n Student
Details ");
System.out.println("\n Student ID =
"+UgObject1.getStudentID());
System.out.println("\n Student full
name (first name first) ="+UgObject1.getStudentName());
System.out.println("\n Students
Major = "+UgObject1.getStudentMajor());
System.out.println("\n Students
Undergraduatelevel = "+UgObject1.getUndergradeLevel());
}
}
PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class...
Create an abstract Student class for Parker University. The class contains fields for student ID number, last name, and annual tuition. Include a constructor that requires parameters for the ID number and name. Include get and set methods for each field; the setTuition() method is abstract. Create three Student subclasses named UndergraduateStudent, GraduateStudent, and StudentAtLarge, each with a unique setTuition() method. Tuition for an UndergraduateStudent is $4,000 per semester, tuition for a GraduateStudent is $6,000 per semester, and tuition for...
A Java Program Purpose: Work with Abstract classes. Purpose: Abstract classes are import because they ensure than any children which inherit from it must implement certain methods. This is done to enforce consistency across many different classes. Problem: Implement a class called Student. This class needs to be abstract and should contain a String for the name, and a String for the major (and they should be private). The class must have a constructor to set the name and major....
C++ In the code cell below, define a class named Student with an integer id and a string name. This class should have a constructor that takes two arguments: one for the id and the other for the name. Then Create another class named CollegeStudent that publicly inherits from Student. This class should have a protected member named major. It should also have a constructor that takes three arguments: id, name, and major. This constructor should delegate initializing the id...
Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...
All question base on Java Se 8 Consider the Top class i public abstract class Topí 2 private 3 protected String name; 4 public intx - 12; int age; e public Top(String name)[ this.namename age0; System.out.println(x); 10 12 public abstract void foo(String f); 13 Create a Middle class that extends the Top class. The class should have a single constructor that takes two input parameters: a String (for name) and int (for age). Your constructor should not have any redundant...
Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src folder, create a package named: edu.ilstu · Import the following files from T:\it168\Labs\lab13. Note that the .txt file must be in the top level of your project, not inside your src folder. o Student.java o StudentList.java o students.txt Carefully examine the Student.java and StudentList.java files. You are going to complete the StudentList class (updating all necessary Javadoc comments), following the instruction in the code....
In Java: Develop a simple class for a Student. Include class variables; StudentID (int), FirstName, LastName, GPA (double), and Major. Extend your class for a Student to include classes for Graduate and Undergraduate. o Include a default constructor, a constructor that accepts the above information, and a method that prints out the contents FOR EACH LEVEL of the object, and a method that prints out the contents of the object. o Write a program that uses an array of Students...
a) Create an abstract class Student. The class contains fields for student Id number, name, and tuition. Includes a constructor that requires parameters for the ID number and name. Include get and set method for each field; setTuition() method is abstract. b) The Student class should throw an exception named InvalidNameException when it receives an invalid student name (student name is invalid if it contains digits). c) Create three student subclasses named UndergradStudent, GradeStudent, and StudentAtLarge, each with a unique...
Java Programming Design a class named Person and its two subclasses named Student and Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. Override the toString method in each class to display the class name and the person's name....
I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student { private String name; private double gpa; private int idNumber; public Student() { this.name = ""; this.gpa = 0; this.idNumber = 0; } public Student(String name, double gpa, int idNumber) { this.name = name; this.gpa = gpa; this.idNumber = idNumber; } public Student(Student s)...