Advertisement
thotfrnk

inclass work.java

Mar 18th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner; //scanner import
  2. public class Main {
  3.     public static void main(String[] args) {
  4.  
  5.         Scanner input = new Scanner (System.in); //scanner declaration
  6.  
  7.         //variable declaration
  8.         String lastName;
  9.         int hours;
  10.         double grossPay, netPay;
  11.         final double STD_PAYRATE = 15.50, WITHHOLDING_RATE = 0.20;
  12.  
  13.         //for user to input last name
  14.         System.out.println("Please enter employee name: ");
  15.         lastName = input.next();
  16.  
  17.         //for user to input hours
  18.         System.out.println("Hours worked for employee: ");
  19.         hours = input.nextInt();
  20.  
  21.         //calculations for gross pay and net pay
  22.         grossPay = hours * STD_PAYRATE;
  23.  
  24.         netPay = grossPay - (grossPay * WITHHOLDING_RATE);
  25.  
  26.         //output statement to show the user their net pay
  27.         System.out.println("Net pay for " +lastName+ "who worked for " +hours+ "hours is: $" +netPay);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement