@GeorgeGibby/

AP Comp Sci 1.07 - Payroll

Java

No description

fork
loading
Files
  • Main.java
Main.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
37
38
39
40
41
42
/*
* Calculates Payroll for an employee.
*
* George Gibby
*
* September 18, 2018
*
* Inputs: Pay per hour
*         Regular hour(s)
*         Overtime hour(s)
*/  

import java.util.Scanner;

public class Main
{
  public static void main(String[] args)
  {
    //initialize the variables
    double payRate;
    double hours;
    double overHours;
    double finalPay;

    //initialize the scanner
    Scanner reader = new Scanner(System.in);

    //ask the user for Inputs
    System.out.print("Pay Rate: ");
    payRate = reader.nextDouble();
    System.out.print("Regular hours: ");
    hours = reader.nextDouble();
    System.out.print("Overtime hours: ");
    overHours = reader.nextDouble();

    //Math
    finalPay = (payRate * hours) + (payRate * (1.5 * overHours));

    //Print the result
    System.out.println("Your pay is $" + finalPay);
  }
}