Instructions:
1. Provide the flowchart, complete code and sample output for all of the questions.
A medium sized company has two types of
employees which are hourly workers and commission workers. Each type of employee
has its own pay code:
Pay Code Employee Type
1 Hourly Worker
2 Commission Worker
The hourly worker is paid RM50 per hour for the first 40 hours he/she works and
"time-and-a-half" (1.5 times the hourly rate of RM50) for each of the hours above 40
hours (overtime hours). The commission worker receives RM500 plus 5.5% of their
weekly sales (e.g. 5.5% of RM1000 is RM55).
You are asked by the company to write a Java program that can determine the salary
for both employee types. The program must implement TWO (2) methods, namely
calculatePayHourlyWorker() and calculatePayCommWorker() to perform
the salary calculations for the respective types of employees. Each of the methods
displays the calculated salary amount.
The input for the program is the pay code and the appropriate information needed to
calculate each employee’s salary based on the pay code. If the pay code entered is a
negative value, the program will terminate. If it is invalid (other than 1 or 2), display
an appropriate error message. The output is the calculated salary, which must be
printed to TWO (2) decimal places.
The format of the input and output is as follows:
The format of the input and output is as follows:
Enter pay code: 1
Enter the number of hours worked: 40
Salary is RM2000.00
Enter pay code: 1
Enter the number of hours worked: 50
Salary is RM2750.00
Enter pay code: 2
Enter the amount of weekly sales: 1000
Salary is RM555.00
Enter pay code: 3
Invalid product code!
Enter pay code: -1
Note: The underline texts are the input to the program
a) Complete the program main() method based on the given description.
b) Complete the calculatePayHourlyWorker() method.
c) Complete the calculatePayCommWorker() method.
You can use this as a guideline:
import java.util.Scanner;
public class SalaryApp {
static Scanner read = new Scanner(System.in);
static int hours;
static double salary;
public static void main(String[] args) {
int paycode;
//TODO: add your code here
}
//complete the calculatePayHourlyWorker() method
public static void calculatePayHourlyWorker() {
}
//complete the calculatePayCommWorker() method
public static void calculatePayCommWorker() {
double sales = 0;
}
}
What I have tried:
I have tried do the coding and get the output based on the question. So, now I havent finish yet about flowcart