Income Estimator Summary Hourly wages of employees are based
Income Estimator
Summary
Hourly wages of employees are based on their hourly rate as well as number of hours worked. Some types of employment/employers will also pay an increased rate for their employees under certain circumstances (e.g. overtime, working during busy seasons, etc.). Write a simple program to help hourly employees estimate their take-home pay before taxes.
Skills Expected
Basic Statements, Expressions, and Primitive Variables
User Input and Printing to Console
Some Commenting
Simple Methods
Assignment Description
Write a program that does the following:
Ask the user for their first name
Ask the user for their last name
Ask the user for an “Hourly Rate”
Ask the user for “Number of hours worked” o Calculate the “Base Income” where
Base Income = Hourly Rate * Hours worked
Ask the user for “Number of overtime hours worked” o Calculate the “Overtime Income” where
Overtime Income = Overtime Hours * Hourly Rate * 1.5
o Challenge*: Ask if there is a special overtime rate and use it in the calculations.
Calculate the “Total Income Before Tax” where
Total Before Tax = Base Income + Overtime Income
“Print the estimated income” (display to the console) that includes, at minimum:
o A header (e.g. “Estimated Income for ___Last Name, First Name____”) o Hourly Rate
o Number of Hours Worked
o Number of Overtime Hours Worked
Correct amounts displayed for Base Income, Overtime Income, and Total before Tax
Challenge*: Ensure that all amounts displayed are formatted with only two significant figures.
o A footer (e.g. a “thank you” message)
Grading Criteria
Program meets requirements described in Assignment Description
Program compiles and runs without errors
Lines of code are easy to understand
Demonstrated use of at least one simple method
Descriptive variable names
Appropriate class header comment block
Solution
HourlyWorkedEmployee.java
import java.util.Scanner;
public class HourlyWorkedEmployee {
public static void main(String[] args) {
//Declaring variables
String firstname,lastname;
double hourly_rate;
int no_of_hours_worked,no_of_overTime_hours_worked;
double base_income,over_income,total_before_tax;
//Scanner class object is used to read the input entered by the user
Scanner kb=new Scanner(System.in);
//Getting the first name entered by the user
System.out.print(\"Enter the Firstname :\");
firstname=kb.next();
//Getting the last name entered by the user
System.out.print(\"Enter the Lastname :\");
lastname=kb.next();
//Getting the hourly rate entered by the user
System.out.print(\"Enter the Hourly rate :\");
hourly_rate=kb.nextDouble();
//Getting the no of hours worked entered by the user
System.out.print(\"Enter the no of hours worked :\");
no_of_hours_worked=kb.nextInt();
//Getting the over time hours worked by the user
System.out.print(\"Enter the no of Over time hours worked :\");
no_of_overTime_hours_worked=kb.nextInt();
//Calculating the base income
base_income=hourly_rate*no_of_hours_worked;
//Calculating the over income
over_income=no_of_overTime_hours_worked*hourly_rate*1.5;
//Calculating the total amount before tax
total_before_tax=base_income+over_income;
//Displaying the results
System.out.println(\"Estimated Income for \"+firstname+\" \"+lastname+\" at Hourly rate of \"+hourly_rate);
System.out.println(\"No of Hours Worked :\"+no_of_hours_worked);
System.out.println(\"No of Over Time Hours Worked :\"+no_of_overTime_hours_worked);
System.out.printf(\"Base Income is :%.2f \",base_income);
System.out.printf(\"OverTime Income is :%.2f \",over_income);
System.out.printf(\"\ Total Income Before tax is :%.2f \",total_before_tax);
System.out.println(\"\ ** Thank You **\");
}
}
_____________________
Output:
Enter the Firstname :Williams
Enter the Lastname :Kane
Enter the Hourly rate :11
Enter the no of hours worked :40
Enter the no of Over time hours worked :9
Estimated Income for Williams Kane at Hourly rate of 11.0
No of Hours Worked :40
No of Over Time Hours Worked :9
Base Income is :440.00 OverTime Income is :148.50
Total Income Before tax is :588.50
** Thank You **
_______________Thank You


