aspose file tools*
The moose likes Beginning Java and the fly likes help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help please" Watch "help please" New topic
Author

help please

BOB SMITH
Greenhorn

Joined: Mar 19, 2006
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61221
    
  66

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10

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

What were you expecting?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
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.


You down with OOP? Yeah you know me!
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
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

Joined: Mar 19, 2006
Posts: 2
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help please