Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Payroll Application

962826Sep 18 2012 — edited Sep 19 2012
Hi - new developer here - this is for a class homework assignment. Not sure what I am doing worng here but I am getting a lot of errors. I am very much so a novice, any feedback would be appreciated. Thanks!

import java.util.Scanner;

public class Payroll {
public static void main (String[] args) {
//Create a scanner
Scanner input = new Scanner(System.in);

//Enter a name
System.out.print("Enter employee's name, e.g. Smith: ");
double name = input.nextDouble();

//Enter number of hours worked
System.out.print("Enter number of hours worked in a week, e.g. 10: ");
double hours = input.nextDouble();

//Enter hourly rate
System.out.print("Enter hourly pay rate, e.g. $6.75: ");
double payRate = input.nextDouble();

//Obtain gross pay
double grossPay = hours * payRate;

//Enter Federal tax withholding rate
System.out.print("Enter federal tax withholding rate in percentage, e.g. 20%: ");
double federal = input.nextDouble();

//Obtain Federal tax withholding rate:
double federalFormula = (federal / 100) * grossPay;

//Enter State tax withholding rate
System.out.print("Enter state tax withholding rate: ");
double state = input.nextDouble();

//Obtain State tax withholding rate:
double stateFormula = (state / 100) * grossPay;

//Display the results
System.out.println("Employee Name: " + name + "\n"
+ "Hours Worked: " + hours + "\n"
+ "Pay Rate: " + payRate + "\n"
+ "Federal Tax Withholding: (" + federal + ")" + federalFormula + "\n"
+ "State Tax Withholding: (" + state + ")" + stateFormula + "\n");
}
}
This post has been answered by Tolls on Sep 18 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2012
Added on Sep 18 2012
14 comments
588 views