Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-24-2008, 08:33 AM
Member
 
Join Date: Feb 2008
Posts: 2
lplopez92 is on a distinguished road
Payroll Part 2, Java
Hi, I'm hoping someone can please help me with this one nagging error in my program. I have to modify the program (from Part 1) so that it continues to request employee info until the user enters 'stop' as an employee name. Also the program has to check to see that both the hourly rate and numbers of hours worked are positive numbers. If they aren't positive, the application should let the user know to enter a positive number. As far as the error goes, I've tried looking for a missing semi colon, an imbalance or junk on previous lines or missing concatenation operatives...plleeeaaaassse help.
Here's my error:
C:\Documents and Settings\Leonard Lopez\Desktop\PayRoll2.java:36: ';' expected
name.setName = input.nextLine());
^
1 error

Tool completed with exit code 1


Here is my program:

// Fig 2.3: PayRoll2.java
// Payroll for Acme Company.
/* This is a payroll program for Acme Company*/
import java.util.Scanner;

public class PayRoll2
{
private static void Quit()

{
System.out.println( "Sign Off" );
System.exit (0);
}
// main method begins execution of Java application
public static void main( String args[] )
{
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );


// create a Payroll object and assign it to PayRoll
double hourlyRate = 0.0; //employees hourly rate of pay
double hoursWorked = 0.0; //total of hours worked during the week
double pay = 0.0; //product of hoursWorked and hourlyRate
String name = "";

if (name.setName().equals( "Stop" ))
{
System.outprintln( "Stop is entered" );
Stop = true;

} //end if
else

System.out.print( "Please Enter Employees Name:" );
name.setName = input.nextLine());
if (name.getName().equals( "Stop"))
{
System.out.println( "Stop is entered" );
Stop = true;

} //end if
else

System.out.print( "Please Enter Total Number of Hours Worked This Week: ");
hoursWorked = input.nextDouble();

if ( hourlyRate < 0.0 );
System.out.println( "Input must be a positive number, reenter hourly rate: ");
System.out.println( "Please Enter Employees Hourly Rate: "); //prompt hourlyRate = input.nextDouble();

pay = hourlyRate * hoursWorked;

System.out.printf( "Employee Name: %s\n",name );

System.out.printf( "Total Pay for the Week: $%.2f\n",pay);
} //end method main

} //end class PayRoll2
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-24-2008, 08:35 AM
Member
 
Join Date: Feb 2008
Posts: 2
lplopez92 is on a distinguished road
Just to let you know. On the error message, the little '^' is actually under the bracket next to the left of the semi-colon. I don't know why it didn't copy over right...thanks again for your help.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-24-2008, 02:55 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,144
hardwired is on a distinguished road
Code:
C:\jexp>javac pr2.java pr2.java:33: ';' expected name.setName = input.nextLine()); ^ 1 error
On line 33 change this
Code:
name.setName = input.nextLine());
to this
Code:
name.setName = input.nextLine();
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help for payroll project in java mageshwari New To Java 2 04-09-2008 03:46 AM
How to get part of a String? eva New To Java 1 12-23-2007 07:58 AM
Inventory part 2 help please badness New To Java 1 12-12-2007 08:51 AM
Help with mathematical part in java lenny Advanced Java 3 08-09-2007 02:55 PM
Part time java Programmer-Indianapolis,IN pegitha Jobs Offered 0 05-08-2007 05:01 PM


All times are GMT +3. The time now is 10:17 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org