simple Java payroll problem

Any help would be appreciated!!
I am taking an introductory course in Java.
I am currently working on a payroll calculation problem.
This particular program should use method readDouble in the Keyboard reader class to gather user inputs(double).
The program must execute in the Terminal I/O from the user inputs.
I am having problems compiling my source code because of some errors (apparently two) that I cannot fiqure out.
I am trying to write a program that calculates weekly pay based on user inputs of the three variables listed below.
The following is my source code...     (with compile errors to follow)



import terminalIO.KeyboardReader;

public class KeyboardReader {
      public static void main( String [ ] args) {
      KeyboardReader reader = new KeyboardReader();

double hourlyRate;      
double regularHours;
double overtimeHours;

//get user imputs

System.out.print("Please enter your hourly pay rate:  \"");
hourlyRate = reader.readDouble();         // hourly rate entered by the user.
system.out.print

System.out.print("Please enter the amount of regular hours worked:  \"");
regularHours = reader.readDouble();       // regular number of hours worked entered by the user.
system.out.print

System.out.print("Please enter the amount of overtime hours worked:  \"");
overtimeHours = reader.readDouble();      // overtime hours worked entered by the user.
System.out.println("");

double overtimeRate = (hourlyrate * 1.5);
double weeklyPay = (hourlyrate * regularhours + overtimerate);

System.out.print("The total weekly pay is:$  \"");
weeklyPay = reader.readDouble();
System.out.println("");

      }
}




The following are the errors I receive when I try to compile it:

C:\ex\newweeklypay.java:20: ';' expected
System.out.print("Please enter the amount of regular hours worked:  \"");
          ^
C:\ex\newweeklypay.java:24: ';' expected
System.out.print("Please enter the amount of overtime hours worked:  \"");
          ^
2 errors
Tool completed with exit code 1


The circumflex (hats?) is under the method selector and this is probably an issue.?.?
I am frustrated, lauren

ps-thanks again
Brayn66Asked:
Who is Participating?
 
objectsCommented:
you need to actually print out the result, it doesn't happen automatically:

eg.

System.out.println("The total weekly pay is:$"+weeklyPay);
0
 
objectsCommented:
> system.out.print

this line is causing the errors, if you want to print a new line then use:L

System.out.println();

(there are two places this needs to be changed)
0
 
Brayn66Author Commented:

I have corrected the case sensitivity issue with the system.out.print

I changed them to:  System.out.println(); and get the following errors when trying to compile:

C:\ex\keyboardreader.java:4: class KeyboardReader is public, should be declared in a file named KeyboardReader.java
public class KeyboardReader {
       ^
C:\ex\keyboardreader.java:2: KeyboardReader is already defined in this compilation unit
import TerminalIO.KeyboardReader;
^
C:\ex\keyboardreader.java:17: cannot resolve symbol
symbol  : method readDouble ()
location: class KeyboardReader
hourlyRate = reader.readDouble();         // hourly rate entered by the user.
                   ^
C:\ex\keyboardreader.java:21: cannot resolve symbol
symbol  : method readDouble ()
location: class KeyboardReader
regularHours = reader.readDouble();       // regular number of hours worked entered by the user.
                     ^
C:\ex\keyboardreader.java:25: cannot resolve symbol
symbol  : method readDouble ()
location: class KeyboardReader
overtimeHours = reader.readDouble();      // overtime hours worked entered by the user.
                      ^
C:\ex\keyboardreader.java:28: cannot resolve symbol
symbol  : variable hourlyrate
location: class KeyboardReader
double overtimeRate = (hourlyrate * 1.5);
                       ^
C:\ex\keyboardreader.java:32: cannot resolve symbol
symbol  : method readDouble ()
location: class KeyboardReader
weeklyPay = reader.readDouble();
                  ^
7 errors

Tool completed with exit code 1



I don't know what happened this time!? lauren
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
objectsCommented:
> C:\ex\keyboardreader.java:4: class KeyboardReader is public, should be declared in a file named KeyboardReader.java

filename needs to be same as poublic class name (case sensitive)

> C:\ex\keyboardreader.java:2: KeyboardReader is already defined in this compilation unit

I'd suggest using a different class name for your class.
0
 
Brayn66Author Commented:
I have named the public class name: newweeklypay
My file name: newweeklypay.java

When I compile, I get the following errors:

C:\ex\newweeklypay.java:7: package terminalIO does not exist
import terminalIO.KeyboardReader;
                          ^
C:\ex\newweeklypay.java:12: cannot resolve symbol
symbol  : class KeyboardReader
location: class newweeklypay
      KeyboardReader reader = new KeyboardReader();
               ^
C:\ex\newweeklypay.java:12: cannot resolve symbol
symbol  : class KeyboardReader
location: class newweeklypay
      KeyboardReader reader = new KeyboardReader();
                                                             ^
3 errors
Tool completed with exit code 1

as you can see, the carrot(^)is under the letter K and I am not understanding why.

Thanks, lauren
0
 
objectsCommented:
> C:\ex\newweeklypay.java:7: package terminalIO does not exist

It cannot find the terminalIO package (containing the KeyboardReader class).
Where is that class currently?
0
 
Brayn66Author Commented:
I don't know.
I am copying examples from the book using a temperature conversion program that ask for a user input in the terminal io.

lauren
0
 
objectsCommented:
Well to use that class you need to have it available somwhere.
0
 
Brayn66Author Commented:
How do I get this class to make it available to use?
0
 
objectsCommented:
> import terminalIO.KeyboardReader;

actually I think that should be:

import TerminalIO.KeyboardReader;
0
 
Brayn66Author Commented:
I have this part:
 import TerminalIO.KeyboardReader;
               ...correct I think.
just to make surewe are on the same sheet here is the source code:


import TerminalIO.KeyboardReader;

public class newweeklypay {
      public static void main( String [] args) {

      KeyboardReader reader = new KeyboardReader();

double hourlyRate;
double regularHours;
double overtimeHours;

//get user imputs

System.out.println("Please enter your hourly pay rate:  \"");
hourlyRate = reader.readDouble();         // hourly rate entered by the user.
System.out.println

System.out.println("Please enter the amount of regular hours worked:  \"");
regularHours = reader.readDouble();       // regular number of hours worked entered by the user.
System.out.println

System.out.println("Please enter the amount of overtime hours worked:  \"");
overtimeHours = reader.readDouble();      // overtime hours worked entered by the user.
System.out.println("");

double overtimeRate = (hourlyRate * 1.5);
double weeklyPay = (hourlyRate * regularHours + overtimeRate);

System.out.println("The total weekly pay is:$  \"");
weeklyPay = reader.readDouble();
System.out.println("");

      }
}

-------------
Here's the errors when I compile:

C:\ex\newweeklypay.java:24: ';' expected
System.out.println("Please enter the amount of regular hours worked:  \"");
         ^
C:\ex\newweeklypay.java:28: ';' expected
System.out.println("Please enter the amount of overtime hours worked:  \"");
          ^
2 errors
Tool completed with exit code 1


--------------
Should I have the class name as: newweeklypay?  This is also what the filename is (newweeklypay.java)

thanks
 
0
 
objectsCommented:
> System.out.println

you've still got problem I described earlier.
0
 
Brayn66Author Commented:
I have corrected and now the terminal IO appears and ask for the inputs(as described in the program).
All seems well until the calculation should occur.

the last thing that comes up is :


The total weekly pay is:$   "
Press any key to continue........


Do you know if it is calculating and if it is, why won't it display??

lauren
0
 
Brayn66Author Commented:
All I lack on this program is getting the calculated results to display. Any ideas? Lauren
0
 
objectsCommented:
because you never actually print it out :)

System.out.println("The total weekly pay is:$  \"");
weeklyPay = reader.readDouble();
System.out.println("");
0
 
Brayn66Author Commented:
I apologize but I don't understand.

My assignment states:
"Wite a program that takes as imputs the hourly wage, total regular hours and total overtime hours and displays an employee's total weekly pay".

Do you think that my formulas are correctly written?

I thought that the results of the formulas calulationed would display in the window as the result.?.?

I feek like it is something minor dealing with the displaying of the calculations OR the calculations are not happening at this point.

thanks! lauren

0
 
Brayn66Author Commented:
You were right all along. One unknown mistake led to the correction of another.
I had not put the output variable in the last statement for it to display in the Terminal IO.
A huge oversight on my part.
I have learned from you and appreciate it.
lauren
0
 
objectsCommented:
no worries :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.