Professional Documents
Culture Documents
The Following Java Program Application Calculates The Weekly Salary of An Employee
The Following Java Program Application Calculates The Weekly Salary of An Employee
The
program determines an employee’s weekly wages. If the hours worked exceed 40, then wages
include overtime payment. . I will be using the JCreator IDE in developing the program.
To start in this tutorial, first open the JCreator IDE, click new and paste the following code.
1. import java.util.*;
2.
3. public class WeeklyWages
4. {
5.
6. static Scanner console = new Scanner(System.in);
7.
8. public static void main(String[] args)
9. {
10.
11. double wages, rate, hours;
12.
13. System.out.print("Enter the working hours:");
14. hours = console.nextDouble();
15. System.out.println();
16.
17. System.out.print("Enter the pay rate:");
18. rate = console.nextDouble();
19. System.out.println();
20.
21.
22. if (hours > 40.0)
23. wages = 40.0 * rate +
24. 1.5 * rate * (hours - 40.0);
25.
26. else
27. wages = hours * rate;
28.
29. System.out.printf("The wages are $%.2f %n",
30. wages);
31.
32. System.out.println();
33.
34. }
35. }
The statement
The statement
The statement
checks whether the value of the variable hours is greater than 40.0
If hours are greater than 40.0, then the wages are calculated, which also includes overtime
payment, the wages are calculated by the statement wages = hours * rate;