Results 1 to 5 of 5
Thread: Payroll part 3 errors help
- 11-18-2009, 07:47 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 13
- Rep Power
- 0
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 classWhen I run it gives me these errors: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
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
- 11-18-2009, 11:56 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,589
- Blog Entries
- 7
- Rep Power
- 17
Your curly braces don't match; check them out.
kind regards,
Jos
- 11-18-2009, 06:06 PM #3
Member
- Join Date
- Nov 2009
- Posts
- 13
- Rep Power
- 0
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
- 11-18-2009, 06:54 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,589
- Blog Entries
- 7
- Rep Power
- 17
Your indentation stinks and you've done your best to hide your }s. You really have to fix that.
kind regards,
Jos
- 03-08-2011, 05:43 AM #5
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
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
-
Need help ASAP with Payroll Program Part 2
By arrech326 in forum New To JavaReplies: 10Last Post: 11-17-2009, 10:17 PM -
Payroll output thingy...
By ShadowUndertow in forum NetBeansReplies: 3Last Post: 08-25-2009, 02:25 AM -
Payroll Project 1 Troubles
By KiskaBaker in forum New To JavaReplies: 3Last Post: 08-16-2009, 12:41 PM -
What is the difference between Semantic Errors and Logical Errors?
By tlau3128 in forum New To JavaReplies: 3Last Post: 03-08-2009, 01:51 AM -
Payroll Part 2, Java
By lplopez92 in forum New To JavaReplies: 2Last Post: 03-24-2008, 01:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks