JCreator Build Errors HELP!!

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2007
Posts: 4
Reputation: ukankissthis is an unknown quantity at this point 
Solved Threads: 0
ukankissthis ukankissthis is offline Offline
Newbie Poster

JCreator Build Errors HELP!!

 
0
  #1
Nov 9th, 2007
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;
}
} }
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,265
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 493
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: JCreator Build Errors HELP!!

 
0
  #2
Nov 9th, 2007
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
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 4
Reputation: ukankissthis is an unknown quantity at this point 
Solved Threads: 0
ukankissthis ukankissthis is offline Offline
Newbie Poster

Re: JCreator Build Errors HELP!!

 
0
  #3
Nov 9th, 2007
I realize that it is 2 files I am wondering if there is a way to combine the 2 in order for the program to run first to get the Payrate and second when you enter Stop it will come up with the information that had previously been entered.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,265
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 493
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: JCreator Build Errors HELP!!

 
0
  #4
Nov 9th, 2007
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1718 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC