Question: import java.util.Scanner; class Person { String firstName, lastName, address, zip, phone; void setData ( ) { Scanner scanner = new Scanner ( System . in
import java.util.Scanner;
class Person
String firstName, lastName, address, zip, phone;
void setData
Scanner scanner new ScannerSystemin;
System.out.printEnter first name: ;
firstName scanner.nextLine;
System.out.printEnter last name: ;
lastName scanner.nextLine;
System.out.printEnter address: ;
address scanner.nextLine;
System.out.printEnter zip code: ;
zip scanner.nextLine;
System.out.printEnter phone number: ;
phone scanner.nextLine;
void display
System.out.printlnfirstName lastName address zip phone;
class CollegeEmployee extends Person
String ssn;
double annualSalary;
String dept;
@Override
void setData
super.setData;
Scanner scanner new ScannerSystemin;
System.out.printEnter SSN: ;
ssn scanner.nextLine;
System.out.printEnter annual salary: ;
annualSalary scanner.nextDouble;
scanner.nextLine; Consume the newline character
System.out.printEnter department: ;
dept scanner.nextLine;
@Override
void display
super.display;
System.out.printlnSSN: ssn;
System.out.printlnSalary $ annualSalary;
System.out.printlnDepartment: dept;
class Faculty extends CollegeEmployee
boolean isTenured;
@Override
void setData
super.setData;
Scanner scanner new ScannerSystemin;
System.out.printIs the faculty member tenured? truefalse: ;
isTenured scanner.nextBoolean;
@Override
void display
super.display;
System.out.printlnFaculty member is isTenured : "not "tenured";
class Student extends Person
String major;
double gpa;
@Override
void setData
super.setData;
Scanner scanner new ScannerSystemin;
System.out.printEnter major: ;
major scanner.nextLine;
System.out.printEnter GPA: ;
gpa scanner.nextDouble;
@Override
void display
super.display;
System.out.println Major: major GPA: gpa;
public class CollegeList
public static void mainString args
Scanner scanner new ScannerSystemin;
Person people new Person; CollegeEmployees Faculty Students
int collegeEmployeeCount ;
int facultyCount ;
int studentCount ;
while true
System.out.printEnter type of person's data C F S or quit Q: ;
String choice scanner.nextLinetoUpperCase;
if choiceequalsQ
break;
switch choice
case C:
if collegeEmployeeCount
peoplecollegeEmployeeCount new CollegeEmployee;
peoplecollegeEmployeeCount setData;
else
System.out.printlnError: Cannot enter more than CollegeEmployees.";
break;
case F:
if facultyCount
people facultyCount new Faculty;
people facultyCount setData;
else
System.out.printlnError: Cannot enter more than Faculty members.";
break;
case S:
if studentCount
people studentCount new Student;
people studentCount setData;
else
System.out.printlnError: Cannot enter more than Students.";
break;
default:
System.out.printlnInvalid choice. Please enter C F S or Q;
break;
System.out.println
College Employees:";
for int i ; i collegeEmployeeCount; i
peopleidisplay;
System.out.println;
System.out.println
Faculty:";
for int i ; i facultyCount; i
peopleidisplay;
System.out.println;
System.out.println
Students:";
for int i ; i studentCount; i
peopleidisplay;
System.out.println;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
