GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/Programs/eduEmpDb.java at main · arshcoder13/Java Expand file tree/ Copy patheduEmpDb.javaMore file actions 139 lines (133 loc) · 3.72 KB / Copy patheduEmpDb.javaFile metadata and controls139 lines (133 loc) · 3.72 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 // An educational institution wishes to maintain a database of employees. Database is divided into number of classes. // This hierarchical relationships are shown in the figure, it also shows minimum information required for each class and define methods to create a database // and retrieve individual info as and when required. import java.util.Scanner; class Staff { // code // name Scanner sc = new Scanner(System.in); public int emp_id; public String name; } class Teacher extends Staff { // subject // publication public String subject, publication; public void getData() { System.out.println("Enter employee details: "); System.out.println("Enter name: "); name = sc.nextLine(); System.out.println("Enter employee id: "); emp_id = sc.nextInt(); System.out.println("Enter subject: "); subject = sc.nextLine(); System.out.println("Enter publication: "); publication = sc.nextLine(); } public void displayData() { System.out.println("Displaying employee details: "); System.out.println("Name: " + name); System.out.println("Employee id: " + emp_id); System.out.println("Subject: " + subject); System.out.println("Publication: " + publication); } } class Typist extends Staff { // speed public double speed; public void getData() { System.out.println("Enter employee details: "); System.out.println("Enter name: "); name = sc.nextLine(); System.out.println("Enter employee id: "); emp_id = sc.nextInt(); System.out.println("Enter speed: "); speed = sc.nextDouble(); } public void displayData() { System.out.println("Displaying employee details: "); System.out.println("Name: " + name); System.out.println("Employee id: " + emp_id); System.out.println("Speed: " + speed); } } class Officer extends Staff { // grade public String grade; public void getData() { System.out.println("Enter employee details: "); System.out.println("Enter name: "); name = sc.nextLine(); System.out.println("Enter employee id: "); emp_id = sc.nextInt(); System.out.println("Enter grade: "); grade = sc.next(); } public void displayData() { System.out.println("Displaying employee details: "); System.out.println("Name: " + name); System.out.println("Employee id: " + emp_id); System.out.println("Grade: " + grade); } } class Regular extends Typist { } class Casual extends Typist { // daily wages public double dwages; public void getData() { System.out.println("Enter employee details: "); System.out.println("Enter name: "); name = sc.nextLine(); System.out.println("Enter employee id: "); emp_id = sc.nextInt(); System.out.println("Enter daily wages: "); dwages = sc.nextDouble(); } public void displayData() { System.out.println("Displaying employee details: "); System.out.println("Name: " + name); System.out.println("Employee id: " + emp_id); System.out.println("Daily wages: " + dwages); } } public class EduEmpDB { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int choice = 0; do { System.out.println("Enter 1 for teacher, 2 for regular typist, 3 for casual typist, 4 for officer, 5 to exit: "); choice = sc.nextInt(); switch (choice) { case 1: Teacher t = new Teacher(); t.getData(); t.displayData(); break; case 2: Regular r = new Regular(); r.getData(); r.displayData(); break; case 3: Casual c = new Casual(); c.getData(); c.displayData(); break; case 4: Officer o = new Officer(); o.getData(); o.displayData(); break; default: if (choice != 5) { System.out.println("Invalid input!"); } else if (choice == 5) { System.out.println("End of program"); } } } while(choice != 5); } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |