Facebook
From Joshua QT, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 63
  1.  
  2. package collegelist;
  3. import java.util.*;
  4.  
  5. public class CollegeList{
  6.  
  7.    
  8.     public static void main(String[] args) {
  9.        
  10.         Scanner ey = new Scanner(System.in);
  11.         Employee emp = new Employee();  
  12.         Faculty f = new Faculty();
  13.         Student stu = new Student();
  14.        
  15.         System.out.print("Press E for Employee, F fo Faculty, S for Student:  ");
  16.         char select = ey.nextLine().charAt(0);
  17.        
  18.        
  19.         if (select == 'E' || select == 'e') {
  20.           System.out.println("Type employee's name, contact number, salary, and department");
  21.           System.out.println("Press enter after every input");
  22.          
  23.           String n = ey.nextLine();
  24.           emp.setName(n);
  25.           String c = ey.nextLine();
  26.           emp.setContactNum(c);
  27.           double sa =  ey.nextDouble();
  28.           emp.setSalary(sa);
  29.           ey.nextLine();
  30.           String de = ey.nextLine();
  31.           emp.setDepartment(de);
  32.          
  33.           System.out.println("--------------------------------------");
  34.           System.out.println("Name: " + emp.getName());
  35.           System.out.println("Contact Number: " + emp.getContactNum());
  36.           System.out.println("Salary: " + emp.getSalary());
  37.           System.out.println("Department: " + emp.getDepartment());
  38.         }
  39.         else if (select == 'F' || select == 'f') {
  40.           System.out.print("Press Y if regular/tenured or N if not.");
  41.                 String stat = ey.nextLine();
  42.                
  43.                 if (stat.equalsIgnoreCase("Y")) {
  44.                     boolean status = true;
  45.                     f.getRegular(status);
  46.                 } else if (stat.equalsIgnoreCase("N")) {
  47.                     boolean status = false;
  48.                     f.getRegular(status);
  49.                 }
  50.                
  51.                 System.out.println("Type faculty member's name, contact number, salary, and department");
  52.                 System.out.println("Press enter after every input");
  53.                
  54.           String n1 = ey.nextLine();
  55.           String c1 = ey.nextLine();
  56.           double sa1 = ey.nextDouble();
  57.           ey.nextLine();
  58.           String de1 = ey.nextLine();
  59.          
  60.           System.out.println("--------------------");
  61.          
  62.           emp.setName(n1);
  63.           emp.setContactNum(c1);
  64.           emp.setSalary(sa1);
  65.           emp.setDepartment(de1);
  66.          
  67.           System.out.println("Name: " + emp.getName());
  68.           System.out.println("Contact Number: " + emp.getContactNum());
  69.           System.out.println("Salary: " + emp.getSalary());
  70.           System.out.println("Department: " + emp.getDepartment());
  71.           System.out.println("Status: " +f.isRegular());
  72.           if(f.isRegular() == true){
  73.                 System.out.println("Status: Regular/Tenured");
  74.                 } else {
  75.                 System.out.println("Status: Not Regular/Tenured");
  76.                 }
  77.         }
  78.         else if (select == 'S' || select == 's') {
  79.           System.out.print("Type your enrolled program: ");
  80.           String sIn = ey.next();
  81.           System.out.print("Type your year level (1-4): ");
  82.           int sIn1 = ey.nextInt();
  83.          
  84.           System.out.println("Type student's name, contact number");
  85.           System.out.println("Press enter after every input");
  86.  
  87.           ey.nextLine();
  88.           String n2 = ey.nextLine();
  89.           String c2 = ey.nextLine();
  90.          
  91.           stu.setProgram(sIn);
  92.           stu.setYearLevel(sIn1);
  93.           stu.setName(n2);
  94.           stu.setContactNum(c2);
  95.          
  96.           System.out.println("--------------------");
  97.          
  98.           System.out.println("Name: " + stu.getName());
  99.           System.out.println("Contact Number: " + stu.getContactNum());
  100.           System.out.println("Program enrolled: " + stu.getProgram());
  101.           System.out.println("Year Level: " + stu.getYearLevel());
  102.          
  103.         }
  104.     }}                  
  105.  
  106. class Person{
  107.     private String name;
  108.     private String contactNum;
  109.    
  110.     public void setName(String n){
  111.         this.name =n;
  112.     }
  113.     public String getName(){
  114.         return name;
  115.     }
  116.     public void setContactNum(String c){
  117.         this.contactNum = c;
  118.     }
  119.     public String getContactNum(){
  120.         return contactNum;
  121.     }
  122. }
  123. class Student extends Person{
  124.     private String program;
  125.     private int yearLevel;
  126.    
  127.     public void setProgram(String p){
  128.         this.program = p;
  129.     }
  130.     public String getProgram(){
  131.         return program;
  132.     }
  133.     public void setYearLevel(int y){
  134.         this.yearLevel = y;
  135.     }
  136.     public int getYearLevel(){
  137.         return yearLevel;
  138.     }
  139. }
  140. class Employee extends Person{
  141.  
  142.     private double salary;
  143.     private String department;
  144.  
  145.     public void setSalary(double salary) {
  146.         this.salary = salary;
  147.     }
  148.  
  149.     public double getSalary() {
  150.         return salary;
  151.     }
  152.  
  153.     public void setDepartment(String department) {
  154.         this.department = department;
  155.     }
  156.  
  157.     public String getDepartment() {
  158.         return department;
  159.     }
  160. }
  161.  
  162. class Faculty extends Employee {
  163.     private boolean status;
  164.    
  165.     public void getRegular(boolean status){
  166.         this.status = status;
  167.     }
  168.     public boolean isRegular(){
  169.        
  170.         return status;
  171.     }  
  172. }
  173.  
  174.