Results 1 to 5 of 5
  1. #1
    arrech326 is offline Member
    Join Date
    Nov 2009
    Posts
    13
    Rep Power
    0

    Default Payroll part 3 errors help

    Java Code:
    // Program: Payroll Program Part 2
    // File:	ProgramPayroll.java
    // Summary: Payroll Calculator that interacts with user to calculate the employee's payroll with the hourly rate and hours worked by the employee.
    // Author:	Charlene Arreche
    // Date:	November 7,2009.
    
    import java.util.Scanner;
    import java.text.NumberFormat;
    
    class EmployeeInfo {
    	
    	private String employee = "";// Declares string variable Employee
    	private double rate, hours, salary = 0;// Declares double variables Rate, Hours and Salary
    	
    	public EmployeeInfo(){}// Creates constructor (Empty constructor)
    	
    	public EmployeeInfo(String employee,double rate, double hours){//Constructor with parameters
    		setEmployee(employee);
    		setRate(rate);
    		setHours(hours);
    	}
    	public void setEmployee(String employee){
    		this.employee = employee;
    	}
    	public String getEmployee(){
    		return this.employee;
    	}
    	public void setRate(double rate){
    		this.rate = rate;
    	}
    	public double getRate(){
    		return rate;
    	}
    	public void setHours(double hours){
    		this.hours = hours;
    	}	
    	public double getHours (){
    		return hours;
    	}
    }// Ends class
    Java Code:
    // Program: Payroll Program Part 2
    // File:	Payroll.java
    // Summary: Payroll Calculator that interacts with user to calculate the employee's payroll with the hourly rate and hours worked by the employee.
    // Author:	Charlene Arreche
    // Date:	October 30,2009.
    
    import java.util.Scanner;//This line allows the user to interact with the application.
    
    public class EmployeeProgram{//Payroll class
    	
    	public static void main(String args[]){			
    		
    		Scanner userInput = new Scanner(System.in);//This line tells the application expects input from the user.
    		
    		System.out.println("Welcome to the Payroll Calculator Application.");//This line welcomes the user to the application.
    		System.out.println("Please enter the employee's name here");//This line prompts the user to input the employee's name.
    		System.out.println("To quit enter stop"); //This line prompts the user to enter the word stop to quit the application
    		
    		EmployeeInfo pro = new EmployeeInfo();// Creates object pro
    		pro.setEmployee(userInput.nextLine());//This line tells the program to expect Employee input from user.
    				while (!pro.getEmployee().toUpperCase().equals("STOP"))//loop while employee not = STOP
    				{
    		System.out.println("Please enter the hourly rate");// This line prompts the user to input the hourly rate for that employee.
    			double rate = userInput.nextDouble();
    				if (rate < 0){
    				System.out.println("Please enter a positive amount.");}
    				else{
    		System.out.println("Please enter how many hours " + employee + " worked this week");}// This line prompts the user to input the hours worked by that employee.
    			double hours = userInput.nextDouble();// This line tells the program to expect Hours input from the user.
    			if (hours <0){
    			System.out.println("Please enter a positive amount.");
    			}
    			else{
    				double salary = rate * hours;
    			}
    	private static void Exit(){
    		System.out.println("Thank you for using the Payroll Application. Good bye!");
    	System.exit (0);}
    	
    	public void displayResult(){
    		System.out.println("The Salary for " + getEmployee()+ "is " + salary +".");
    	}
    	
    		userInput.close();	
    }//End class
    When I run it gives me these errors:

    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    employee cannot be resolved
    Syntax error, insert "}" to complete Block
    Syntax error, insert "}" to complete Block

    at EmployeeProgram.main(EmployeeProgram.java:28)

    Please help!
    -Charlene

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    Your curly braces don't match; check them out.

    kind regards,

    Jos

  3. #3
    arrech326 is offline Member
    Join Date
    Nov 2009
    Posts
    13
    Rep Power
    0

    Post FIxed but with errors

    Java Code:
    // Program: Payroll Program Part 2
    // File:	ProgramPayroll.java
    // Summary: Payroll Calculator that interacts with user to calculate the employee's payroll with the hourly rate and hours worked by the employee.
    // Author:	Charlene Arreche
    // Date:	November 7,2009.
    
    
    class EmployeeInfo {
    	
    	private String employee = "";// Declares string variable Employee
    	private double rate, hours = 0;// Declares double variables Rate, Hours and Salary
    	
    	public EmployeeInfo(){}// Creates constructor (Empty constructor)
    	
    	public EmployeeInfo(String Employee, double Rate, double Hours){//Constructor with parameters
    		employee = Employee;
    		rate = Rate;
    		hours = Hours;
    	}
    	public void setEmployee(String Employee){
    		employee = Employee;
    	}
    	public String getEmployee(){
    		return employee;
    	}
    	public void setRate(double Rate){
    		rate = Rate;
    	}
    	public double getRate(){
    		return rate;
    	}
    	public void setHours(double Hours){
    		hours = Hours;
    	}	
    	public double getHours (){
    		return hours;
    	}
    	public double getSalary(){
    		double salary = rate * (double)hours;
    			return salary;
    	}
    }// Ends class
    
    
    // Program: Payroll Program Part 2
    // File:	Payroll.java
    // Summary: Payroll Calculator that interacts with user to calculate the employee's payroll with the hourly rate and hours worked by the employee.
    // Author:	Charlene Arreche
    // Date:	October 30,2009.
    
    import java.util.Scanner;//This line allows the user to interact with the application.
    import java.text.NumberFormat;
    
    public class EmployeeProgram{//Payroll class
    	
    	public static void main(String args[]){			
    		
    		Scanner userInput = new Scanner(System.in);//This line tells the application expects input from the user.
    		EmployeeInfo pro = new EmployeeInfo();// Creates object pro
    		
    		boolean STOP = false;
    		while (!pro.getEmployee().toUpperCase().equals(STOP))//loop while employee not = STOP
    				{
    		System.out.println("Welcome to the Payroll Calculator Application.");//This line welcomes the user to the application.
    		System.out.println("Please enter the employee's name here");//This line prompts the user to input the employee's name.
    		System.out.println("To quit enter STOP as name");//This line prompts the user to enter the word stop to quit the application	
    		String employee = userInput.nextLine();//This line tells the program to expect Employee input from user.
    			if (employee.equals("STOP")){
    			Exit();
    			}
    			else{
    		System.out.println();
    		System.out.println("Please enter the hourly rate");// This line prompts the user to input the hourly rate for that employee.
    			double rate = userInput.nextDouble();
    				while(rate < 0){
    				System.out.println("Please enter a positive amount.");
    				rate = userInput.nextDouble();}
    		System.out.println();
    		System.out.println("Please enter how many hours the employee worked this week");}// This line prompts the user to input the hours worked by that employee.
    			double hours = userInput.nextDouble();// This line tells the program to expect Hours input from the user.
    				while(hours < 0){
    				System.out.println("Please enter a positive amount.");
    				hours = userInput.nextDouble();}
    		System.out.println();
    		
    		double salary = [COLOR="Red"]rate[/COLOR] * hours;
    		
    		System.out.println("The salary of " + employee + "is " + [COLOR="red"]currency[/COLOR].format(salary));
    		System.out.println();
    		System.out.println(employee + " worked "+ hours + " hours with a payrate of " + [COLOR="red"]rate[/COLOR]);
    		System.out.println();
    				}
    	}
    	private static void Exit(){
    		System.out.println("Thank you for using the Payroll Application. Good bye!");
    	System.exit (0);
    	}
    			
    }//End class

    These are the errors is giving me now.

    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    rate cannot be resolved
    currency cannot be resolved
    rate cannot be resolved

    at EmployeeProgram.main(EmployeeProgram.java:42)

    ***I highlited in red the errors

    From what I understand I shoud import java.lang but which one?? :S

    Thanks,
    -Charlene

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    Your indentation stinks and you've done your best to hide your }s. You really have to fix that.

    kind regards,

    Jos

  5. #5
    annabentleys is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Default Payroll

    With SurePayroll.com, you get payroll features that save you time and headaches for an affordable price. Our payroll service lets you focus on growing your business.

Similar Threads

  1. Need help ASAP with Payroll Program Part 2
    By arrech326 in forum New To Java
    Replies: 10
    Last Post: 11-17-2009, 11:17 PM
  2. Payroll output thingy...
    By ShadowUndertow in forum NetBeans
    Replies: 3
    Last Post: 08-25-2009, 03:25 AM
  3. Payroll Project 1 Troubles
    By KiskaBaker in forum New To Java
    Replies: 3
    Last Post: 08-16-2009, 01:41 PM
  4. Replies: 3
    Last Post: 03-08-2009, 02:51 AM
  5. Payroll Part 2, Java
    By lplopez92 in forum New To Java
    Replies: 2
    Last Post: 03-24-2008, 02:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •