CASE STUDY: Calculate Salary at a University
There are two classes of employees at the university,
namely Lecturers and Ordinary Staff.
All employees get the same starting salary, which is
1,500,000
Additional salaries for lecturers are calculated from the number of
credits they can afford
Additional staff salaries are calculated from the number of
attendances per month
Make class diagrams and programs with Java language to print all employee salaries
===========================
JAVA PROGRAM
===========================
///////////////////TestSalary.java//////////////////////////
import java.util.Scanner;
/*************
Test salary of employees
*************/
public class TestSalary {
public static void main(String[] args){
Scanner sc = new
Scanner(System.in);
System.out.println("Enter pay per
credit for lecturer: ");
double payPerCredit =
sc.nextDouble(); //read value from user
System.out.println("Enter pay per
atttendance for ordinary staff: ");
double payPerAttendance =
sc.nextDouble(); //read value from user
sc.close();
//create instances and calculate
salary
Employee e1 = new
Lecturer(50,payPerCredit);
System.out.println("Salary for
"+e1+ " is = "+e1.calculateSalary());
Employee e2 = new
Lecturer(37,payPerCredit);
System.out.println("Salary for "+
e2 +" is = "+e2.calculateSalary());
Employee e3 = new
OrdinaryStaff(28,payPerAttendance);
System.out.println("Salary for
"+e3+ " is = "+e3.calculateSalary());
Employee e4 = new
OrdinaryStaff(25,payPerAttendance);
System.out.println("Salary for
"+e4+ " is = "+e4.calculateSalary());
}
}
//////////////////////////////Employee.java//////////////////////////////
/**
* Employer :abstract class
*/
public abstract class Employee {
//private field: starting salary
private double startingSalary;
public Employee(){
this.startingSalary = 1500000;
//set it up
}
//getter for stating salary
public double getStartingSalary() {
return startingSalary;
}
//abstract metho: to be implemented in derived
classes
public abstract double calculateSalary();
}
/////////////////////////////Lecturer.java//////////////////////////////////////
/**
*Class Lecturer derived from Employee class
*/
public class Lecturer extends Employee{
//2 private fields
private int numberOfCredits;
private double payPerCredit;
//constructor
public Lecturer(int numberOfCredits,double
payPerCredit) {
super();
this.numberOfCredits =
numberOfCredits;
this.payPerCredit =
payPerCredit;
}
@Override
public double calculateSalary() {
//calculate total salary
return (getStartingSalary() +
(numberOfCredits * payPerCredit));
}
@Override
public String toString() {
return "Lecturer [numberOfCredits="
+ numberOfCredits + ", payPerCredit=" + payPerCredit + "]";
}
}
/////////////////////////////OrdinaryStaff.java////////////////////////////////////////
/**
*Class OrdinaryStaff derived from Employee class
*/
public class OrdinaryStaff extends Employee{
//2 private fields
private int attendancePerMonth;
private double payPerAttendance;
//constructor
public OrdinaryStaff(int attendancePerMonth,double
payPerAttendance) {
super();
this.attendancePerMonth =
attendancePerMonth;
this.payPerAttendance =
payPerAttendance;
}
@Override
public double calculateSalary() {
//calculate total salary
return (getStartingSalary() +
(attendancePerMonth * payPerAttendance));
}
@Override
public String toString() {
return "OrdinaryStaff
[attendancePerMonth=" + attendancePerMonth + ", payPerAttendance="
+ payPerAttendance
+ "]";
}
}
=======================================
OUTPUT
========================================
Enter pay per credit for lecturer:
375.75
Enter pay per atttendance for ordinary staff:
25.45
Salary for Lecturer [numberOfCredits=50, payPerCredit=375.75] is =
1518787.5
Salary for Lecturer [numberOfCredits=37, payPerCredit=375.75] is =
1513902.75
Salary for OrdinaryStaff [attendancePerMonth=28,
payPerAttendance=25.45] is = 1500712.6
Salary for OrdinaryStaff [attendancePerMonth=25,
payPerAttendance=25.45] is = 1500636.25
CASE STUDY: Calculate Salary at a University There are two classes of employees at the university,...
JAVA ONLY. For this assignment you will create an employee application, containing contact information, salary, and position. You will also define the type of company. Is it an engineering firm, a supermarket, or a call center? Once the application has been completed, I should be able to perform a query for any piece of information associated with each employee. For instance, if I search for employees who make over $50,000, all of the employees whose salaries are greater than $50,000 should...
The University Accommodation Office Case Study The director of the University Accommodation Office requires you to design a database to assist with the administration of the office. The requirements collection and analysis phase of the database design process has provided the following data requirements specification for the University Accommodation Office database followed by examples of query transactions that should be supported by the database. Data Requirements Students(entity) The data stored for each full-time student includes: the banner number, name (first...
Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...
Q1: The following question are based on these database tables: EMPLOYEE FNAME MIDINT LNAME SSN BDATE ADDRESS SEX SALARY SUPER_SSN Dept_No James A Borg 123123123 Houston, TX M 55000 Null 1 Franklin S Wong 234234234 Houston, TX M 40000 123123123 5 John Q Smith 345345345 Houston, TX M 30000 234234234 5 Jennifer L Wallace 456456456 Bellaire, TX F 43000 123123123 4 Alicia M Zalaya 567567567 Spring, TX F 25000 456456456 4 Ramesh R Narayan 678678678 Humble, TX M 38000 234234234...
1. Employees and overriding a class method The Java program (check below) utilizes a superclass named EmployeePerson (check below) and two derived classes, EmployeeManager (check below) and EmployeeStaff (check below), each of which extends the EmployeePerson class. The main program creates objects of type EmployeeManager and EmployeeStaff and prints those objects. Run the program, which prints manager data only using the EmployeePerson class' printInfo method. Modify the EmployeeStaff class to override the EmployeePerson class' printInfo method and print all the...
Two employees have been hired, at a monthly salary of $2,960 each. The following transactions occurred during Janu of the current year. ch. 2 2 2 January 1 2 3 4 5 6 7 نم نم لم له له لما فما فما لما $6,000 is paid for 12 months' insurance starting January 1. (Record as an asset.) $4,800 is paid for 12 months of rent beginning January 1. (Record as an asset.) FDI borrows $30,000 cash from First State Bank...
Case Study - II Wyatt Public Ltd Company is well known for its welfare activities and employee oriented schemes in manufacturing industry from more than ten decade. The company employs more than 500 workers and 100 administrative staff and 50 management level employees. The top level management views all the employees at same level. This can be clearly understood by seeing the uniform of the company which is same for all starting from MD to floor level workers. The company...
so these t-accounts Two employees have been hired, at a monthly salary of $2,100 each. The following transactions occurred during January of the current year. NNNNNN $4,200 is paid for 12 months' Insurance starting January 1. (Record as an asset.) 53,600 is paid for 12 months of rent beginning January 1. (Record as an asset.) FDI borrows $30,000 cash from First State Bank at 4% annual interest; this note is payable in two years. A delivery van is purchased using...
need retained earnings and Balance sheet Two employees have been hired, at a monthly salary of $2,100 each. The following transactions occurred during January of the current year. Ch. January $4,200 is paid for 12 months" insurance starting January 1. (Record as an asset.) 53,600 is paid for 12 months of rent beginning January 1. (Record as an asset.) FDI borrows $30, ce cash from First State Bank at ex annual interest; this note is payable in two years. A...
The following is for java programming. the classes money date and array list are so I are are pre made to help with the coding so you can resuse them where applicable Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university class Student [ private String lastName; private String firstName; private Address address; private String degreeProgram; private IDNumber studentNumber; // Constructors and methods omitted. class Staff private String lastName;...