import java.util.Scanner;

class EmployeeInfo

{

   private double wage;

    private double hours;

    private String empName;



    public EmployeeInfo()

    {

        wage = 0.0;

        hours = 0.0;

        empName = "";

    }

    public void setwage(double wage)

    {

        wages = wage;

    }

    public double getwage()

    {

        return wages;

    }

    public void sethours(double hours)

    {

        hours = hours;

    }

    public double gethours()

    {
       return hours;
    }

    public void setempName(String name)
    {

        employeeName = empName;

    }

    public String getempName()

    {

        return empName;

    }

    public double calculateWeeklyPay()

    {

        return wages * hours;

    }

} // end class


import java.util.Scanner;
// Anthony NMontemayor
// Payroll Program pt 2
// 9/1/14
public class Pay3
{
    //main method to execute program
    public static void main (String args[] )
    {
        //main execution
        Scanner input = new Scanner( System.in );
        //variables
        String empName;
        float wage;
        float hours;
        float pay;
        double overTimePay;
        boolean stop=false;


            while( !stop ){ 
            System.out.printf( "Enter employee name or 'stop' to exit:"); // Asks for users name if they want to exit enter 'stop'
            empName = input.next();

            if(empName.equalsIgnoreCase("stop")) // if 'stop' is entered program will exit, if not continue
            stop = true;
            else{

                System.out.printf( "What is the hourly rate?"); // promts user for his/her hourly rate
                wage = input.nextFloat();


            while (wage <=0)

                {
                System.out.print("Please enter an amount above 0 dollars"); // enters in dollars
                wage = input.nextFloat();
                }


        System.out.print( "How many hours?"); // states how many hours worked
        hours = input.nextFloat();

            while (hours <=0)
                {
                System.out.print("Please enter an amount above 0 hours:"); // repeats how many hours
                hours = input.nextFloat();

                }

        pay = hours * wage;//multiplication
        //using printf and println
        System.out.println("Employee:" + empName); // States users name
        System.out.printf("Hourly Rate: $%.2f\n", wage); // states users hourly rates
        System.out.println("Regular Hours worked:" + hours); // states users hours worked in a week
        System.out.printf("Gross Pay: $%.2f\n", pay); // states gross pay 
        }
        }
    }//end main
}//end class

Right now I'm getting an error saying in line 83 and 84 Error: class, interface, or enum expected import java.until.Scanner;
java.lang.double;
I'm sure it's an easy fix but I'm puzzeled I've tried numberous of solutions and I'm stuck.

You have already imported Scanner at the very beggining comment out/remove line 83

I think another error pops up when I remove this, I will try it again though

Okay so it worked, and I fixed a few other errors although how would I know if the constructor is working properly?

Well, what you are doing is setting a couple of veriables to some initial values during creationg of objects of the type of your class. I assume you want to create an object of class EmployeeInfo and then set what the user enters to his existing variables. Is that right?

If so - in the main method you basically have to fix it completely
First create new object of type EmployeeInfo and name is for example employeeSlavi

Then if you want to set the wage of that employee you call the newly created object employeeSlavi and access its methods for setting its variables.

For example employeeSlavi.setWage(int number) , by doing so you can set the wage of the employee. In your case if you enter it manually you could get the value of variable number using the scanner object.

EDIT: - To answer your question - How would you know if the constructor has set your variables. Create an object of that type such as the employeeSlavi one. Then use System.out.println(employeeSlavi.getWage()); If this returns the value that you have initialized newly created objects to be, then it works

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.