PRGM::2A
import java.util.Scanner;
class Staff
{
String StaffID, Name, Phone, Salary;
Scanner input = new Scanner(System.in);
void read()
{
System.out.println("Enter StaffID");
StaffID = input.nextLine();
System.out.println("Enter Name");
Name = input.nextLine();
System.out.println("Enter Phone");
Phone = input.nextLine();
System.out.println("Enter Salary");
Salary = input.nextLine();
}
void display()
{
System.out.format("%-15s", "STAFFID: ");
System.out.format("%-15s", StaffID);
System.out.println();
System.out.format("%-15s", "NAME: ");
System.out.format("%-15s", Name);
System.out.println();
System.out.format("%-15s", "PHONE:");
System.out.format("%-15s", Phone);
System.out.println();
System.out.format("%-15s", "SALARY:");
System.out.format("%-15s", Salary);
System.out.println();
}
}
class Teaching extends Staff
{
String Domain, Publication;
void read_Teaching()
{
super.read(); // call super class read method
Scanner input = new Scanner(System.in);
System.out.println("Enter Domain");
Domain = input.nextLine();
System.out.println("Enter Publication");
Publication = input.nextLine();
}
void display()
{
System.out.println();
super.display(); // call super class display() method
System.out.format("%-15s", "DOMAIN:");
System.out.format("%-15s", Domain);
System.out.println();
System.out.format("%-15s", "PUBLICATION:");
System.out.format("%-15s", Publication);
System.out.println();
}
}
class Technical extends Staff
{
String Skills;
void read_Technical()
{
super.read(); // call super class read method
Scanner input = new Scanner(System.in);
System.out.println("Enter Skills");
Skills = input.nextLine();
}
void display()
{
System.out.println();
super.display(); // call super class display() method
System.out.format("%-15s", "SKILLS:");
System.out.format("%-15s", Skills);
System.out.println();
}
class Contract extends Staff
{
String Period;
void read_Contract()
{
super.read(); // call super class read method
Scanner input = new Scanner(System.in);
System.out.println("Enter Period");
Period = input.nextLine();
}
void display()
{
System.out.println();
super.display(); // call super class display() method
System.out.format("%-15s", "PERIOD:");
System.out.format("%-15s", Period);
System.out.println();
}
}
class Staffdetails
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter number of staff details to be created");
int n = input.nextInt();
Teaching steach[] = new Teaching[n];
Technical stech[] = new Technical[n];
Contract scon[] = new Contract[n];
// Read Staff information under 3 categories
for (int i = 0; i < n; i++)
{
System.out.println("Enter Teaching staff information");
steach[i] = new Teaching();
steach[i].read_Teaching();
}
for (int i = 0; i < n; i++)
{
System.out.println("Enter Technical staff information");
stech[i] = new Technical();
stech[i].read_Technical();
}
for (int i = 0; i < n; i++)
{
System.out.println("Enter Contract staff information");
scon[i] = new Contract();
scon[i].read_Contract();
}
// Display Staff Information
System.out.println("Staff Details:");
System.out.println();
System.out.println("-----TEACHING STAFF DETAILS-----");
for (int i = 0; i < n; i++)
{
steach[i].display();
}
System.out.println();
System.out.println("-----TECHNICAL STAFF DETAILS-----");
for (int i = 0; i < n; i++)
{
stech[i].display();
}
System.out.println();
System.out.println("-----CONTRACT STAFF DETAILS-----");
for (int i = 0; i < n; i++)
{
scon[i].display();
}
}
}
Comments
Post a Comment