payroll - " stateTaxRate =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/**Trinity Martin * Week 01 * Lab 1.2 Task 1 * This program calculates a payroll statement based on the users input.It does so without a GUI. */ import java.util.Scanner; i public class Payroll { public static void main(String[] args){ p Scanner myScanner = new Scanner (; //Variables for calculations String employee; int hours; double hourlyPay, federalTaxRate, stateTaxRate, federalTax, stateTax, grossRate, totalDeduction, netPay; //Input information System.out.print("Please enter employees full last name: "); employee =; System.out.print("Enter number of hours worked: "); hours = myScanner.nextInt(); System.out.print("Enter hourly pay:$ "); hourlyPay = myScanner.nextDouble(); System.out.print("Enter the federal tax withholding rate, in decimal form: "); federalTaxRate = myScanner.nextDouble(); System.out.print("Enter the state tax withholding rate,in decimal form:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: "); stateTaxRate = myScanner.nextDouble(); //Calculations grossRate = hours * hourlyPay; federalTax = grossRate * federalTaxRate; //Calculates Federal Tax in decimal form stateTax = grossRate * stateTaxRate; //Caculates State tax rate totalDeduction = federalTax + stateTax; //Calculates total tax deductions netPay = grossRate - totalDeduction; //Calculates pay after deductions //Output information for user System.out.println("Employee name: " + employee); System.out.println("Hours Worked: " + hours); System.out.println("Hourly Wage: " + hourlyPay); System.out.println("Federal Tax Withholding Rate %" + federalTax); System.out.println("State Tax Withholding Rate %" + stateTax); System.out.println("Total Deduction:$ " + totalDeduction); System.out.println("Gross Pay is:$ " + grossRate); System.out.println("Net Pay is:$ " + netPay); } }...
View Full Document

This note was uploaded on 07/26/2011 for the course IT 218 taught by Professor Accampo,e during the Spring '11 term at ITT Tech Pittsburgh.

Ask a homework question - tutors are online