Alright, well I thought I had it all good and corrected but then it was giving me an error of <no main class found>. So, I went back through and edited it some mroe and got it to where there were no errors BUT the program wouldnt run, it just told me build successful and thats it. So, I played around again with it and now I am back to square one. Here is my whole source code. I am at my end with this.
import java.util.Scanner;
public class Main
{
// main method begins execution of Java application
public static void Main(String empName, double hoursWorked, double payRate, double total)
{
boolean stop = false; // controls if loop below is executed
while (!stop)
{
// create Scanner to obtain input from command window
Scanner input = new Scanner(System.in);
System.out.print("Enter employee's name or stop to quit: "); // prompt for name
String EmpName = input.nextLine(); // read employee's name entered
if (EmpName.equals("stop"))
{
System.out.println("This program has ended successfully.");
stop = true;
input.close();
break;
}
else
{
double PayRate; // First number multiplied
double HoursWorked; // Second number multiplied
//double total; // Total of PayRate * HoursWorked
System.out.print("Enter the pay rate per hour of the employee: "); // prompt for rate
PayRate = input.nextDouble(); // read payrate of employee
while (PayRate <= 0) // Validate for positive number
{
System.out.println();
System.out.println("Pay rate must be a positve number. ");
System.out.print("Please enter pay rate per hour again: ");
PayRate = input.nextDouble();
System.out.println();
}
System.out.print("Enter the employee's hours worked this pay week: "); // prompt for Hours
HoursWorked = input.nextDouble();
while (HoursWorked <= 0) // validate for positive number
{
System.out.println();
System.out
.println("Hours worked must be a positive number. ");
System.out.print("Please enter hours worked this pay week again: ");
HoursWorked = input.nextDouble(); //read hourly rate of pay
System.out.println();
}
//Employee employee = new Employee();
Employee employee = new Employee(empName, hoursWorked, payRate, total);
System.out.printf( "Employee Name: %s, Weekly pay is $%d%n",
employee.empName, employee.getWeeklyPay() );
// total = (double) PayRate * HoursWorked; // Multiply PayRate by HoursWorked
System.out.println();
// System.out.println("Employee: " + EmpName); //display name
// System.out.println("Number of hours worked this pay week: " + HoursWorked); //display hours worked
// System.out.printf("Employee's Pay: $%,.2f\n", total); //display pay rate
System.out.println();
System.out.println();
} // end else
} //end while
} // end main
} // end class
class Employee
{
public String empName;
double hoursWorked;
double payRate;
double total;
public Employee(String name, double hours, double rate)
{
this.empName = name;
this.hoursWorked = hours;
this.payRate = rate;
computeWeeklyPay();
}
private void computeWeeklyPay() {
total = (double) hoursWorked * (double) payRate;
}
public double getWeeklyPay(){
return total;
}
}