216k views
4 votes
What is the problem in this program;

class Main {
public static void main(String[] args) {
String userChoice;

String userName;

double hrsWorked = 0;
double payRate = 0.00;
double taxRate1 = 0.25;
double taxRate2 = 0.50;

double grossPay = 0.00;
double taxAmt = 0.00;
double netPay = 0.00;


scanner in = new scanner( System.in );

System.out.println("Please enter your first name ==> \\");
userName = in.next();


System.out.println("Do you want to compute your net pay? \\");
System.out.println("Enter Y for yes or N for no ==> ");
userChoice = in.next();


if (userChoice.equals("Y")) {
System.out.println("\\ Please enter the number of hours you worked ==>");
hrsWorked = in.nextInt();


System.out.println("\\ Please enter your pay rate ==> $");
payRate = in.nextFloat();

grossPay = payRate * hrsWorked;

taxAmt = (grossPay >= 500) ? grossPay * taxRate2 : grossPay * taxRate1;

netPay = grossPay - taxAmt;

System.out.println( "\\ " + userName + " you said you worked " + hrsWorked + " hours at $" + payRate + "\\");
System.out.println("which means you earned a gross amount of $" + grossPay + " \\");
System.out.println("and you paid $" + taxAmt + " in taxes\\");
System.out.println("so your net pay is $" + netPay + " \\");}
else {System.out.println("\\ Thank you " + userName + " then I will not computer your net pay \\");
System.out.println(" Thank you and please come again. \\");
}
}
}
also, this done repl.it PLEASE HELP ASP

User Ryuman
by
4.9k points

1 Answer

7 votes

Answer:

You should import java.util.*; at the top, and capitalize the Scanner class:

Scanner in = new Scanner( System.in );

A detail is that the scanner needs to be closed once you're done with it:

in.close();

User Tmoasz
by
5.2k points