0% found this document useful (0 votes)
131 views3 pages

College List

This document defines a CollegeList class with a main method that uses a switch statement to collect input from the user to create objects for an Employee, Faculty, or Student. It prompts the user to enter details like name, contact number, salary, department, program, and year level. The input is used to create objects and display the attributes of each type of object. It extends the Person class and uses inheritance, polymorphism, and encapsulation concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views3 pages

College List

This document defines a CollegeList class with a main method that uses a switch statement to collect input from the user to create objects for an Employee, Faculty, or Student. It prompts the user to enter details like name, contact number, salary, department, program, and year level. The input is used to create objects and display the attributes of each type of object. It extends the Person class and uses inheritance, polymorphism, and encapsulation concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

import java.util.

*;
public class CollegeList {

public static void main(String[] args){


Person P = new Person();
Employee E = new Employee();
Faculty F = new Faculty();
Student S = new Student();
String key;
String role;

Scanner input = new Scanner(System.in);


System.out.print("Press E for Employee, F for faculty, S for
Student: ");
key = input.nextLine();

switch(key){
case "e":
case "E":

System.out.println("Type employee's name, Contact number, salary and


department.");
System.out.println("Press Enter after every input.");

E.setName(input.nextLine());
E.setContactnum(input.next());
E.setSalary(input.nextDouble());
E.setDepartment(input.next());

System.out.println("-------------------------");
System.out.println("Name: "+E.getName());
System.out.println("Contact Number: "+E.getContactnum());
System.out.println("Salary: "+E.getSalary());
System.out.println("Department: "+E.getDepartment());
break;

case "F":
case "f":
System.out.println("Press Y if the Faculty member is
regular/tenured or N if not.");
role = input.nextLine();

System.out.println("Type Employee's name, Contact number, salary and


department.");
System.out.println("Press Enter after every input.");

F.setName(input.next());
F.setContactnum(input.next());
F.setSalary(input.nextDouble());
F.setDepartment(input.next());

if(role.equalsIgnoreCase("Y")){
F.isRegular();

System.out.println("-------------------------");
System.out.println("Name: "+F.getName());
System.out.println("Contact Number: "+F.getContactnum());
System.out.println("Salary: "+F.getSalary());
System.out.println("Department: "+F.getDepartment());
System.out.println("Status: Regular");
break;
}

else if(role.equalsIgnoreCase("N")){
System.out.println("-------------------------");
System.out.println("Name: "+F.getName());
System.out.println("Contact Number: "+F.getContactnum());
System.out.println("Salary: "+F.getSalary());
System.out.println("Department: "+F.getDepartment());
System.out.println("Status: Not Regular");
break;
}
else{
System.out.println("Your status is Invalid, Please Try
Again.");
}

case "s":
case "S":
System.out.println("Type your enroll Student program(Ex. BSIT, BSTM)
and your year level(Integer 1 to 4). ");
System.out.print("Program: ");

S.setProgram(input.next());

System.out.print("Year Level: ");

S.setYearlevel(input.nextInt());

System.out.println("Type Student's name, and Contact number.");


System.out.println("Press Enter after every input.");

S.setName(input.next());
S.setContactnum(input.next());

System.out.println("-------------------------");
System.out.println("Name: " + S.getName());
System.out.println("Contact Number: "+ S.getContactnum());
System.out.println("Program: " + S.getProgram());
System.out.println("Year Level: " + S.getYearlevel());
break;
}
}

package collegelist;

class Person{
private String name;
private String contactNum;

public void setName(String N){


name = N;
}
public String getName(){
return name;
}

public void setContactnum(String C){


contactNum = C;
}

public String getContactnum(){


return contactNum;
}

class Employee extends Person {


private double salary;
private String department;

public void setSalary(double S){


salary = S;
}
public double getSalary(){
return salary;
}
public void setDepartment (String D) {
department = D;
}
public String getDepartment(){
return department;
}
}

class Student {
private String program;
private int yearLevel;

public void setProgram(String P){


program = P;
}
public String getProgram(){
return program;
}
public void setYearLevel(int Y) {
yearLevel = Y;
}
public int getYearLevel(){
return yearLevel;
}
}

class Faculty extends Employee {


private boolean status;
public boolean isRegular(){
return true;
}

You might also like