These are the errors:
class PayRoll is public, should be declared in a file named PayRoll.java class PayRoll2 is public, should be declared in a file named PayRoll2.java
And this is my code when I get those errors.
import java.util.Scanner;
public class PayRoll {
public static void main(String args[]) {
PayRoll2 runPayRoll = new PayRoll2();
runPayRoll.getDataFromUser();
}
}
public class PayRoll2
{
public void getDataFromUser() {
Scanner stringInput = new Scanner( System.in );
Scanner dubInput = new Scanner(System.in);
boolean keepGoing = true;
System.out.print("\nType the word STOP for name to quit");
System.out.println();
while(keepGoing){
System.out.print( "\nPlease Enter Employee Name: " );
String name = stringInput.nextLine();
if (name.equals("STOP") || name.equals("Stop") || name.equals("stop"))
{
keepGoing = false;
return;
}
System.out.print( "\nPlease Enter Total Number of Hours Worked This Week: ");
double hoursWorked = dubInput.nextDouble();
while( hoursWorked < 0.00 )
{
System.out.print( "\nInput must be a positive number, reenter hours worked: ");
hoursWorked = dubInput.nextDouble();
}
System.out.print( "\nPlease Enter Employees Hourly Rate: ");
double hourlyRate = dubInput.nextDouble();
while ( hourlyRate < 0.00 )
{
System.out.print( "\nInput must be a positive number, reenter hourly rate: ");
hourlyRate = dubInput.nextDouble();
}
double pay = hourlyRate * hoursWorked;
System.out.print( "\n\nEmployee Name: " + name );
System.out.print( "\nTotal Pay for the Week: $" + pay);
System.out.println();
}
}
}
And Knowledge, were you talking about me missing curly brackets, or Pill?
This post has been edited by inf4mi5: 17 June 2009 - 04:18 PM

New Topic/Question
This topic is locked




MultiQuote




|