Right now I'm having a problem getting my program to run, it compiles with no errors. The only previous error I had was that it stated reached end of file while parsing which I think I fixed. Can anyone help me?

import java.util.Scanner;


public class Payyroll2
{
    public static void main( String[] args )
    {

        Scanner input = new Scanner( System.in );

            String EmployeeName;
            double hourpay; // hourly wages entered
            double hoursworked; // number of hours worked entered
            double weeklypay; // calculates weekly pay
            boolean end = false; // is the input name stop
            while (end = false)
            {

            hourpay = -1; // both initiated to be -1;
            hoursworked = -1;
            System.out.print("Enter employee name:" ); //Requests employee name
            EmployeeName = input.nextLine();
            if(EmployeeName.toLowerCase().equals("stop"))
            {

                end = true;  
            }

            {
            System.out.print( "Enter Hourly Wage:" ); //Asks for wages
            hourpay = input.nextDouble(); // States wages entered

            while (hoursworked < 0) // hourly 


            System.out.print( "Enter hours worked:" ); // asks for hours
            hoursworked = input.nextDouble(); //States hours worked
            }

            System.out.print("Weekly Salary is: $" + hourpay*hoursworked);
            weeklypay=input.nextDouble();

        }   
        } // end method main
    } // end 

Recommended Answers

All 4 Replies

Replace

while (end = false)

With

while (end == false)

Or

while (!end)

The error I recieve after I changed it was illegal start of expression

Please post the new code.

 if(EmployeeName.toLowerCase().equals("stop"))
{
end = true;
}

replace this by:
end = EmployeeName.toLowerCase().equals("stop");

you should indent your code more properly, and re-think all the opening and closing brackets.

if(EmployeeName.toLowerCase().equals("stop"))
{
end = true;
}
{ // -> this makes little sense to me.

also, try and follow naming conventions, it 'll make your code easier to read.
if you followed oussama's recommendation, it could not lead to an illegal expression error. what did you change?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.