In: Computer Science
XYZ holdings have many branches. Each branch has a
name and is located in a different province.
Each branch has several departments such as marketing, finance,
sales and customer relations.
For a department to exist there must be employees employed in each
of the departments.
An employee is ether a permanent staff member or a temporary staff
member. The difference
between these two types of employees exist in the facts that
permanent staff earns a fixed salary
of R30 000 every month and has a medical aid benefit whereas
temporary staff members has an
hourly rate of R400 per hour and their monthly salary is dependent
on the number of hours
worked each month multiplied by their hourly rate. Temporary staff
members also do not have a
medical aid benefit. All employees, however, have a name, surname
and employee number.
Q.2.1 Write the pseudocode for class
TemporaryEmployee. Also, ensure that you
indicate the relationship between the TemporaryEmployee and
Employee
class.
(17)
Q.2.2 Using pseudocode, write the mainline logic that will make use
of the
appropriate methods in the TemporaryEmployee class to calculate the
monthly
salary of a temporary employee. Your mainline logic should prompt
the user
for the values needed.
Java programming
Logic and Design
package learning;
import java.util.*;
class Employee{
String name;
String surname;
String employeeNumber;
}
class TemporaryEmployee extends Employee{
int hoursWorked;
static boolean medicalAid=false;
TemporaryEmployee(int hours){
hoursWorked = hours;
}
int salary() {
return 400*hoursWorked;
}
}
class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the number of Hours worked: ");
int hours = input.nextInt();
TemporaryEmployee E1 = new TemporaryEmployee(hours);
System.out.println("Salary: " + E1.salary());
}
}
OUTPUT: