4 Replies - 928 Views - Last Post: 08 October 2012 - 04:42 AM Rate Topic: -----

#1 BeBe922  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-September 12

Cannot find symbol for new object

Posted 07 October 2012 - 12:43 AM

The compiler states, error: cannot find symbols. It show two errors. The compiler shows both capitalize "E" in Employee as errors. Do not understand why. When I change to lower case letters I receive the same errors. I hope I posted my code correctly this time. I am still a newbie and still learning how to correctly post. Thanks before hand.



import java.util.Scanner;													//program will use class scanner to obtain user input
 import java.text.NumberFormat;												//program will use class number format to format integer output
 import java.util.Locale;													//program will use U S currency
 
//PayrollProgramPartIII class starts
 public class PayrollProgramPartIII
 {
	//main method begins to execute Java application
	public static void main(String args[])
	{
		//variable specifications
		String EmployeeName;															//placeholder for employee name
		float HourlyRate;																//placeholder for hourly rate
		float HoursWorked;																//placeholder for hours worked
		float WeeklyPay;																//placeholder for total weekly pay[results of hourly rate times total hours worked for week]
		
		//create scanner to obtain input from keyboard
		Scanner input = new Scanner(System.in);
		
		//set currency to U S Dollars[$]
		NumberFormat uscurrency = NumberFormat.getCurrencyInstance(Locale.US);
		
		//display welcome message
		System.out.println();															//display empty line
		System.out.println("WELCOME TO PAYROLL PROGRAM PART III !!!");					//display welcome message
		System.out.println();															//display empty line
		
		//continous loop --> till ("stop") is entered for EmployeeName
		  while(true)
		  {
		//display empty line
		System.out.println();
		
		//prompt for employee name
		System.out.print("Enter Employee Name or Stop to EXIT Program):");				//prompt message
		EmployeeName = input.nextLine();												//read employee name
		
		//verify if user entered "stop" to end program
		if ( EmployeeName.equalsIgnoreCase("stop") )
	{
		break;																			//break the inifinite while loop
	}
	
	do
	{
	
		//prompt for employee hourly rate
		System.out.print("Enter Hourly Rate:    ");										//prompt message
		HourlyRate = input.nextFloat();													//read employee hourly rate
		if (HourlyRate < 0)
		{
			System.out.println("Enter Positive Amount Only!!!");						//display error message
		}
	} while(HourlyRate < 0);															//end while statement
	
	do
	{
		//prompt for total hours worked
		System.out.print("Enter Hours Worked:   ");										//primpt message
		HoursWorked = input.nextFloat();												//read total hours employee worked
		if (HoursWorked < 0)
		{
			System.out.println("Enter Positive Amount Only!!!");						//display error message
		}
	} while (HoursWorked < 0);															//end while statement
	
	//create new employee object called "emp"
	employee emp = new employee(EmployeeName, HourlyRate, HoursWorked);
	
	//dispaly results
	System.out.println();																//display empty line
	System.out.println("EMPLOYEE NAME: " + emp.getEmployeeName());
	System.out.println("EMPLOYEE WEEKLY PAY:  "  + uscurrency.format(WeeklyPay));
	
	input.nextLine();															//this is required to go to next line --> input.nextDouble() doesn't do this, therefore must force 
		}//end while statement
		
	//display exit message
	System.out.println();														//display empty line
	System.out.print("EXITING PAYROLL PROGRAM PART III !!!!");					//display exit message
	System.out.println();														//display empty line
	}//end method main
	
}//PayrollProgramPartIII class ends


Is This A Good Question/Topic? 0
  • +

Replies To: Cannot find symbol for new object

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Cannot find symbol for new object

Posted 07 October 2012 - 01:10 AM

The compiler is telling you that it doesn't know what the object 'employee' or 'Employee' is. It's undefined and/or a class that doesn't exist, at least not where the compiler can find it. Do you have an employee or Employee class as part of your project?
Was This Post Helpful? 0
  • +
  • -

#3 BeBe922  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-September 12

Re: Cannot find symbol for new object

Posted 07 October 2012 - 06:56 PM

OK I think I understand, I have create the class "Employee", however; now the compiler is stating: Line 75: illegal start of expression

 import java.util.Scanner;													//program will use class scanner to obtain user input
 import java.text.NumberFormat;												//program will use class number format to format integer output
 import java.util.Locale;													//program will use U S currency
 
//PayrollProgramPartIII class starts
 public class PayrollProgramPartIII
 {
	//main method begins to execute Java application
	public static void main(String args[])
	{
		//variable specifications
		String EmployeeName;															//placeholder for employee name
		float HourlyRate;																//placeholder for hourly rate
		float HoursWorked;																//placeholder for hours worked
		float WeeklyPay;																//placeholder for total weekly pay[results of hourly rate times total hours worked for week]
		
		//create scanner to obtain input from keyboard
		Scanner input = new Scanner(System.in);
		
		//set currency to U S Dollars[$]
		NumberFormat uscurrency = NumberFormat.getCurrencyInstance(Locale.US);
		
		//display welcome message
		System.out.println();															//display empty line
		System.out.println("WELCOME TO PAYROLL PROGRAM PART III !!!");					//display welcome message
		System.out.println();															//display empty line
		
		//continous loop --> till ("stop") is entered for EmployeeName
		  while(true)
		  {
		//display empty line
		System.out.println();
		
		//prompt for employee name
		System.out.print("Enter Employee Name or Stop to EXIT Program):");				//prompt message
		EmployeeName = input.nextLine();												//read employee name
		
		//verify if user entered "stop" to end program
		if ( EmployeeName.equalsIgnoreCase("stop") )
	{
		break;																			//break the inifinite while loop
	}
	
	do
	{
	
		//prompt for employee hourly rate
		System.out.print("Enter Hourly Rate:    ");										//prompt message
		HourlyRate = input.nextFloat();													//read employee hourly rate
		if (HourlyRate < 0)
		{
			System.out.println("Enter Positive Amount Only!!!");						//display error message
		}
	} while(HourlyRate < 0);															//end while statement
	
	do
	{
		//prompt for total hours worked
		System.out.print("Enter Hours Worked:   ");										//primpt message
		HoursWorked = input.nextFloat();												//read total hours employee worked
		if (HoursWorked < 0)
		{
			System.out.println("Enter Positive Amount Only!!!");						//display error message
		}
	} while (HoursWorked < 0);															//end while statement
	
	//create new employee class called "emp"
		public Employee(getEmployeeName);														
		System.out.println();															//display empty line
		Scanner s = new Scanner(System.in);
		String name = s.next();
		return name;
	Employee emp = new Employee(EmployeeName, HourlyRate, HoursWorked);
	
	//dispaly results
	System.out.println();																//display empty line
	System.out.println("EMPLOYEE NAME: " + emp.getEmployeeName());
	System.out.println("EMPLOYEE WEEKLY PAY:  "  + uscurrency.format(WeeklyPay));
	
	input.nextLine();															//this is required to go to next line --> input.nextDouble() doesn't do this, therefore must force 
		}//end while statement
		
	//display exit message
	System.out.println();														//display empty line
	System.out.print("EXITING PAYROLL PROGRAM PART III !!!!");					//display exit message
	System.out.println();														//display empty line
	}//end method main
	
}//PayrollProgramPartIII class ends


I'm sorry it is line 68
public Employee(getEmployeeName);

Was This Post Helpful? 0
  • +
  • -

#4 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Cannot find symbol for new object

Posted 08 October 2012 - 02:46 AM

That's not how you create a class, a method, or a variable. You should review the basics.
Was This Post Helpful? 0
  • +
  • -

#5 BeBe922  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-September 12

Re: Cannot find symbol for new object

Posted 08 October 2012 - 04:42 AM

Thanks, I figured it out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1