| | |
JCreator Build Errors HELP!!
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2007
Posts: 4
Reputation:
Solved Threads: 0
Ok, I am getting 2 errors on line 65 it says class or interface expected and again on line 65 saying { expected. The assignment is to Modify the Payroll Program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate. Make sure the program maintains all the functionality required in previous assignments and your source code is readable and well documented.
This is what I have so far and cannot figure out how to fix the errors.
// WeeklyPay2.java
import java.io.*;
import java.text.*;
public class WeeklyPay2
{
public static void main (String[] args)throws Exception
{
DataInput keyboard = new DataInputStream(System.in);
DecimalFormat currency = new DecimalFormat("$ 0.00");
String temp;
char response;
// Variable declaration
String employee_name;
float wage_rate, hours_worked;
while (true)
{
// User Input
System.out.print("Please enter the employee's name: ");
employee_name = keyboard.readLine();
if (employee_name.equalsIgnoreCase("stop"))
break;
System.out.print("Wage rate ($/hour): ");
temp = keyboard.readLine();
wage_rate = Float.valueOf(temp).floatValue();
while (wage_rate < 0)
{
System.out.print("Invalid input. Please enter a positive value: ");
temp = keyboard.readLine();
wage_rate = Float.valueOf(temp).floatValue();
}
System.out.print("Hours worked per week: ");
temp = keyboard.readLine();
hours_worked = Float.valueOf(temp).floatValue();
while (hours_worked < 0)
{
System.out.print("Invalid input. Please enter a positive value: ");
temp = keyboard.readLine();
hours_worked = Float.valueOf(temp).floatValue();
}
// Output
System.out.println("");
System.out.println(employee_name + "'s weekly pay is " + currency.format(wage_rate * hours_worked) + "\n\n\n");
}
System.out.print("\n\nHit 'Enter' to end...");
response = (char)System.in.read();
}
}
//Employee.java
{public class Employee.java
{
// VARIABLES
private String name;
private float wage_rate, hours_worked;
// CONSTRUCTOR METHOD
public Employee(String name, float wage_rate, float hours_worked)
{
this.name = name;
this.wage_rate = wage_rate;
this.hours_worked = hours_worked;
}
public float getWeeklyPay()
{
return wage_rate * hours_worked;
}
public String getName()
{
return name;
}
} }
This is what I have so far and cannot figure out how to fix the errors.
// WeeklyPay2.java
import java.io.*;
import java.text.*;
public class WeeklyPay2
{
public static void main (String[] args)throws Exception
{
DataInput keyboard = new DataInputStream(System.in);
DecimalFormat currency = new DecimalFormat("$ 0.00");
String temp;
char response;
// Variable declaration
String employee_name;
float wage_rate, hours_worked;
while (true)
{
// User Input
System.out.print("Please enter the employee's name: ");
employee_name = keyboard.readLine();
if (employee_name.equalsIgnoreCase("stop"))
break;
System.out.print("Wage rate ($/hour): ");
temp = keyboard.readLine();
wage_rate = Float.valueOf(temp).floatValue();
while (wage_rate < 0)
{
System.out.print("Invalid input. Please enter a positive value: ");
temp = keyboard.readLine();
wage_rate = Float.valueOf(temp).floatValue();
}
System.out.print("Hours worked per week: ");
temp = keyboard.readLine();
hours_worked = Float.valueOf(temp).floatValue();
while (hours_worked < 0)
{
System.out.print("Invalid input. Please enter a positive value: ");
temp = keyboard.readLine();
hours_worked = Float.valueOf(temp).floatValue();
}
// Output
System.out.println("");
System.out.println(employee_name + "'s weekly pay is " + currency.format(wage_rate * hours_worked) + "\n\n\n");
}
System.out.print("\n\nHit 'Enter' to end...");
response = (char)System.in.read();
}
}
//Employee.java
{public class Employee.java
{
// VARIABLES
private String name;
private float wage_rate, hours_worked;
// CONSTRUCTOR METHOD
public Employee(String name, float wage_rate, float hours_worked)
{
this.name = name;
this.wage_rate = wage_rate;
this.hours_worked = hours_worked;
}
public float getWeeklyPay()
{
return wage_rate * hours_worked;
}
public String getName()
{
return name;
}
} }
If this was your code you would know that is actauly 2 java files in one you try to compile as just one file! ! !
//Employee.java
//Employee.java
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
There is no need to combine them in one file. You just need to iplement some methods for it to work as you need to...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Binary Recursion Function Errors - Help!! (C++)
- build errors in vc++ (C++)
- Weird build errors that are not even in my program Please help!! (C++)
- C++ Build Errors (C++)
- 37 build errors! (VB.NET)
- curl / gd2 apache build errors (Linux Servers and Apache)
- Two Build Errors involving my code. (C++)
Other Threads in the Java Forum
- Previous Thread: a homework on methods, constructors etc
- Next Thread: Compilation Errors ---please help me with my program
Views: 1718 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener android api apple applet application arguments array arrays automation binary bluetooth character chat class classes client code component consumer database desktop draw eclipse encode error event exception file fractal ftp game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me java javac javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie number object online oracle print printf problem program programming project properties recursion researchinmotion rotatetext rsa scanner score screen server set size sms socket sort sql string swing template test textfields threads time transfer tree tutorial-sample update windows working xstream






