Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help please

 
BOB SMITH
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a program that takes user input of dollars, euros, and yen. Converts the yen and euros to dollars, keeps a running total and prints the total when the user chooses to exit program. The following program works fine except when I choose to exit the program it does not give me the total of all of the amounts that were entered. It only gives me the amount of the last input. Can someone give me a clue about what I am doing wrong?


[ March 25, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"WARRIOR ONE",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It seems to work ok for me. 1.0 + 1.24 + 0.0092 = 2.2492

What were you expecting?
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first, you should switch the statement not 50 million if statements, it would clean up your code a lot.

and have a count in the loop that adds the converted number of dollars to count again until they quit the program,

and do/while loop to be precise..

i think this will help...

and remember to set count =0.
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob,

How many sites are you planning on posting this into? You got help in two threads for this same code this morning on the Sun forums and now here as well.
 
BOB SMITH
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's good to get different ideas on how to write the best programs. As you notice different programmers have different ways of writing programs that produce the same result.
 
Paul Clapham
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah. That's the excuse that all the cross-posters use. However JavaRanch has a rule against cross-posting: CarefullyChooseOneForum. In my opinion you have been violating that rule.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic