-
Java question
This compiles and runs as expected. The question is Is this the best way to accomplish this task.
Code:
import java.util.Scanner; // program uses Scanner
public class WeekTwoCheckPoint {
public static void main(String[] args) {
Scanner input = new Scanner( System.in );
float PayRate;
float HoursWorked;
float GrossPay;
System.out.println( "Please enter employee name:" ); // input employee name
String EmployeeName = input.nextLine();
System.out.println( "Please enter employee pay rate:" ); //input emplyee rate
PayRate = input.nextFloat();
System.out.println( "Please enter hours worked:" ); //input hours worked
HoursWorked = input.nextFloat();
GrossPay = HoursWorked * PayRate; // calculate gross pay
System.out.print( EmployeeName + "'s gross pay is $" ) ; // output results to console
System.out.printf ("%6.2f",GrossPay);
System.out.println(); // insert blank line
System.out.println(); // insert blank line
} // end of method
} // end of class
-
Re: Java question
Yes, it looks normal, but there is a one problem here - you don't check user input for errors
-
Re: Java question
I know that was not part of the assignment, but it is for this week.
-
Re: Java question
yes this looks normal...i will try to complile it...
be back