Click here to Skip to main content
15,887,464 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Updated 29-Jan-22 18:31pm
v3

1 solution

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Just posting your homework assignment and saying "I haven't finished" isn't going to get you anywhere.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900