-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPay.java
36 lines (29 loc) · 938 Bytes
/
Pay.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//Captain-Price-TF-141
import java.util.Scanner; // Needed for the Scanner class
/**
This program calculates the user's gross pay.
*/
public class Pay
{
public static void main(String[] args)
{
// Create a Scanner object to read from the keyboard.
Scanner keyboard = new Scanner(System.in);
// Identifier declarations
double hours; // Number of hours worked
double rate; // Hourly pay rate
double pay; // Gross pay
// Display prompts and get input.
System.out.print("How many hours did you work? ");
hours = keyboard.nextDouble();
System.out.print("How much are you paid per hour? ");
rate = keyboard.nextDouble();
// Perform the calculations.
if(hours <= 40)
pay = hours * rate;
else
pay = (hours - 40) * (1.5 * rate) + 40 * rate;
// Display results.
System.out.println("You earned $" + pay);
}
}