Need help with payroll program

I am a student new to learning Java. I am to use a constructor to store and retrieve data; however, I can not get my constructor to work. Any tips would be greatly appreciated. I recieve errors for private string name under class Employee, error on public void Employee, and error on string name = Emp_name under public void Employee. All three errors say "cannot find symbol"

symbol : class string

location : class employee

I have been messing with this for 2 hours now, I don't know if my problem is so obvious I am over looking it or what.

import java.util.Scanner; // program uses class Scanner

import java.text.NumberFormat; // used to format currency

public class Employee

{

private float rate;

private float hours;

private string name;

// Constructor to store data

public void Employee( string Emp_name, float PayRate, float Hours_worked )

{

string name = Emp_name;

float rate = PayRate;

float hours = Hours_worked;

} // Constructor end

//main method begins execution of Java application

public static void main( String args[] )

{

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

String Emp_name = input.nextLine(); //read employee's name entered

if (Emp_name.equals("stop")) //check for sentinal

{

System.out.println( "Thank you, program has ended.");

stop = true;

}

else

{

float PayRate; // First number multiplied

float Hours_worked; // Second number multiplied

float total; // Total of PayRate * Hours_worked

System.out.print( "Enter the pay rate of the employee: "); //prompt

PayRate = input.nextFloat(); //read payrate of employee

while (PayRate <= 0) // Validate for positive number

{

System.out.println(); // Enter blank line

System.out.println( "Pay rate must be a positve number. " );

System.out.print( "Please enter pay rate again: ");

PayRate = input.nextFloat(); //read payrate of employee

System.out.println(); //Enter blank line

}

System.out.print( "Enter the employee's hours worked: "); //prompt

Hours_worked = input.nextFloat(); //read hourly rate of pay

while (Hours_worked <= 0) // validate for positive number

{

System.out.println(); //Enter a blank line

System.out.println( "Hours worked must be a positive number. ");

System.out.print( "Please enter hours worked again: ");

Hours_worked = input.nextFloat(); //read hourly rate of pay

System.out.println(); //Enter a blank line

}

total = (float)PayRate * Hours_worked; // Multiply PayRate by Hours_worked

System.out.println(); //Enter blank line

System.out.println( "Employee: " + Emp_name ); //display name

System.out.println( "Number of hours worked: " + Hours_worked ); //display hours worked

System.out.printf( "Employee's Pay: $%,.2f\n", total); //display GPA

System.out.println(); //Enter's blank line

System.out.println(); //Enter's blank line

} // end else

} //end while

} // end main

} // end class Employee

[3425 byte] By [javahelp44a] at [2007-11-27 6:58:27]
# 1
number 1) constructors don't have return type. Get rid of the void
petes1234a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 2
2) every "string" change to "String" Java is case sensitive.These are small errors, but programming languages require precision and are very unforgiving.Good luck!/PeteMessage was edited by: petes1234
petes1234a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 3
Ok, I removed the "void", but still did not help my errors. But thanks for your advice!
javahelp44a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 4
don't get rid of the void in the main method, or any other methods that need it. just in your constructor. All methods must have a return type. Constructors are different, but then again, constructors are not methods. They're a different animal entirely.
petes1234a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 5
Ok, I changed those. now I get an error wanting ; after pubic Employee. when I put that semicolon in, I get all kinds of errors.
javahelp44a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 6
Hi,I suggest plz check the naming conventions, because java is casesensitive.Please let me know still if u have any problems in accessing.
Satyanarayanaraoa at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 7
Thanks Pete, I do understand the part of having void in the "main" statement.
javahelp44a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 8

I made the changes and your program works perfectly. Please repost your new code (but use code tags -- you can find out about them [url=http://forum.java.sun.com/help.jspa?sec=formatting]here[/url]).

Also post the exact text of your error message. They are there for a reason as they pretty much hold the key to what you are doing wrong.

Incidently, here is my version of your code. It is unchanged from your original except with the changes I mentioned above. I second that mention of your studying the java naming conventions:

import java.util.Scanner; // program uses class Scanner

import java.text.NumberFormat; // used to format currency

public class Employee

{

private float rate;

private float hours;

private String name;

// Constructor to store data

public Employee(String Emp_name, float PayRate, float Hours_worked)

{

String name = Emp_name;

float rate = PayRate;

float hours = Hours_worked;

} // Constructor end

// main method begins execution of Java application

public static void main(String args[])

{

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

String Emp_name = input.nextLine(); // read employee's name entered

if (Emp_name.equals("stop")) // check for sentinal

{

System.out.println("Thank you, program has ended.");

stop = true;

}

else

{

float PayRate; // First number multiplied

float Hours_worked; // Second number multiplied

float total; // Total of PayRate * Hours_worked

System.out.print("Enter the pay rate of the employee: "); // prompt

PayRate = input.nextFloat(); // read payrate of employee

while (PayRate <= 0) // Validate for positive number

{

System.out.println(); // Enter blank line

System.out.println("Pay rate must be a positve number. ");

System.out.print("Please enter pay rate again: ");

PayRate = input.nextFloat(); // read payrate of employee

System.out.println(); // Enter blank line

}

System.out.print("Enter the employee's hours worked: "); // prompt

Hours_worked = input.nextFloat(); // read hourly rate of pay

while (Hours_worked <= 0) // validate for positive number

{

System.out.println(); // Enter a blank line

System.out

.println("Hours worked must be a positive number. ");

System.out.print("Please enter hours worked again: ");

Hours_worked = input.nextFloat(); //read hourly rate of pay

System.out.println(); //Enter a blank line

}

total = (float) PayRate * Hours_worked; // Multiply PayRate by Hours_worked

System.out.println(); //Enter blank line

System.out.println("Employee: " + Emp_name); //display name

System.out.println("Number of hours worked: " + Hours_worked); //display hours worked

System.out.printf("Employee's Pay: $%,.2f\n", total); //display GPA

System.out.println(); //Enter's blank line

System.out.println(); //Enter's blank line

} // end else

} //end while

} // end main

} // end class Employee

petes1234a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 9
Thankyou very much Pete for your help!!.. my program now compiles. You get my stars!!!
javahelp44a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 10
YW, what was wrong?
petes1234a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...
# 11

The only thing that was wrong seems to be the correct capital letters. It was my own mistake that after I made changes I did not click on a different line to let netbeans recheck my changes, so I was sitting here thinking I still had an error, when I did not. Thank you very much once again for your help!!

javahelp44a at 2007-7-12 18:49:05 > top of Java-index,Java Essentials,New To Java...