-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpayRoll.java
More file actions
51 lines (34 loc) · 1.07 KB
/
payRoll.java
File metadata and controls
51 lines (34 loc) · 1.07 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package Chapter2.Examples;
/**
* Created by RupGautam on 3/15/17.
*/
import java.util.Scanner;
/**
* Chapter 2: Reading Keyboard Input
* Page: 87
* This program demonstrates the Scanner class
*/
public class payRoll {
public static void main(String[] args) {
String name; // To hold a name
int hours; // Hours worked
double payRate; // Hourly pay rate
double grossPay; // Gross pay
// Create a Scanner object to read input from user
Scanner keyboard = new Scanner(System.in);
// Get the user's name
System.out.print("What is your name: ");
name = keyboard.nextLine();
// Get the number of hours worked this week
System.out.print("How many hours did you work this week? ");
hours = keyboard.nextInt();
// Get User's hourly pay rate
System.out.print("What is your pay rate? ");
payRate = keyboard.nextDouble();
// Calculate the gross pay
grossPay = hours * payRate;
//Display the resulting payment
System.out.println("Hello, " + name);
System.out.println("Your gross pay is 4" + grossPay);
}
}