I am stuck on stupid with this payroll java program the user is prompt to enter
ID: 664691 • Letter: I
Question
I am stuck on stupid with this payroll java program the user is prompt to enter the company's info: name,number of employees and tody's datef)the user should be prompt to enter employee info; first name and last, pay rate(dollars per hour) and # hours workedg)should calculate the paycheck amount and display the info that would normally be on a checkf,g should be repeated(will be inside a loop) all values should validated with a while loop: number of employees, must be postive, the date today, will be a string and so we wont test it correct fromat., employees payrate- must be postive number and should be less than $75.00per hour; number hour worked moust be + number and must be less than 72 hours(should be tested with 2-3 employees.use variety of valuse and be sure to test with bad values to test input validation loops
import java.util.*;
public class Week02_Exercise03
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
double hourRate;
double payNet;
double workedHours;
double payGross;
double deductionTax;
System.out.print("Enter the name of your company");
String compName = in.nextLine();
System.out.print("Enter hourly rate for: $ ");
hourRate = in.nextDouble();
while (hourRate < 75.00 )
{
System.out.println("Please enter only positive: $ " );
hourRate = in.nextDouble();
System.out.print("Enter the total hours worked: ");
workedHours = in.nextDouble();
while (workedHours < 72)
{
System.out.print("Enter a positive number only: ");
workedHours = in.nextDouble();
payNet = payGross - deductionTax;
System.out.println("Net pay: $ ");
System.out.println();
}
deductionTax = payGross*.14;
System.out.print("Federal Taxes: $", deductionTax);
System.out.println();
}
}help me please
Explanation / Answer
import java.util.Scanner; import java.text.NumberFormat; public class Wages { public static void main(String[] args) { Scanner scan = new Scanner(System.in); NumberFormat fmt = NumberFormat.getCurrencyInstance(); System.out.print("Enter hours worked: "); double hours = scan.nextDouble(); System.out.print("Enter hourly rate: "); double rate = scan.nextDouble(); double tot = 0; if (hours>40){ double extra = hours-40; hours = 40; tot = hours*rate+(extra*(rate*1.5)); } else{ tot = hours*rate; } System.out.print(" Gross wages = "+fmt.format(tot)); } } /* Program Output Enter hours worked: 45 Enter hourly rate: 10 Gross wages = $475.00 Enter hours worked: 55 Enter hourly rate: 100 Gross wages = $6,250.00 Enter hours worked: 50 Enter hourly rate: 100 Gross wages = $5,500.00 Enter hours worked: 12 Enter hourly rate: 21.34 Gross wages = $256.08 */
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.