/* * Created on Aug 24, 2006 */ package samplecode; // ignore this import java.util.Scanner; // this is required to find the Scanner class. /** * This is an example of simple text input/output to * and from the console. * */ public class ComputeWages { public static void main (String [] args) { System.out.println("Welcome to your paycheck"); System.out.println(); // create a line after this message System.out.print("How many hours did you work? "); // Ask user for hours worked. Scanner keyboard = new Scanner(System.in); // create a new keyboard object that we can use to read // inputs from the user. int hoursWorked; // a place to store the number of hours worked. hoursWorked=keyboard.nextInt(); // ask the user for an integer number and store it in hoursWorked. System.out.println("You worked "+hoursWorked+" hours."); System.out.print("What is your pay rate in dollars per hour? "); double payRate; // a place to store the hourly rate of pay. payRate=keyboard.nextDouble(); // ask the user for a floating point number and store it in payRate System.out.println("You are paid $"+payRate+" per hour."); double wages=payRate*hoursWorked; // compute wages System.out.println("Your total wages are: $"+wages); double ssTax=wages*0.075; // calculate social security tax System.out.println("Your social security taxes are: $"+ssTax); System.out.println("Your take home pay is: $"+(wages-ssTax)); } }