permaculture playing cards*
The moose likes Beginning Java and the fly likes Newbie problem - HELP! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Newbie problem - HELP!" Watch "Newbie problem - HELP!" New topic
Author

Newbie problem - HELP!

Robert Adams
Greenhorn

Joined: May 06, 2004
Posts: 2
I am having problems with this while loop when exiting. First I can enter valid info, when I want to exit I have to place a #1 in the share price JOptionPane and then a -1 to quit in the number of shares JOptionPane if I want to get any kind of a summary report. When I do this the number of shares are correct, number of transactions are correct, but the calculation of final pay due which is $100 base pay plus commission over $40 and commission over $40 is incorrect.
I feel like I am in a loop, Please help.
Bob

[ edited to preserve formatting using the [code] and [/code] UBB tags, and to remove the evil tab characters -ds ]
[ May 06, 2004: Message edited by: Dirk Schreckmann ]
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Using a local variable in the condition statement in the while loop is awkward since the "-1" alters it and thus your data that uses its value.
Another possibility is to make up a boolean such as enterMoreData and ask the user to validate it, ie, have them enter something special to exit, during each loop. If you get the signal to stop at the bottom all you need to do is set the boolean value to false. The next round evaluates to false and you're out of the loop. If you do the asking and checking/validating at the top of the loop you can use "break" to exit the loop and process your data.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Newbie problem - HELP!
 
Similar Threads
Using .equals in a while statement
Beginner Java Question
Program Problem
Recompile with -Xlint:unchecked for details.
Did I do this right? (Interest calculator)