# Help on exchange rate project

Page 1 of 1

## 3 Replies - 884 Views - Last Post: 10 February 2013 - 06:58 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=311724&amp;s=992b960fb2179a71c80c2b108844fadb&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 rrmv951r

Reputation: 1
• Posts: 8
• Joined: 02-February 13

# Help on exchange rate project

Posted 09 February 2013 - 03:08 PM

the purpose of this project is simple it prompts the user to input the current exchange rate between U.S dollars and Japanese yen then it prompts the user to enter the amount of dollars he or she wants to convert to yen. It does the calculations right but how do i get it to only ask for the exchange rate once...and also when i enter "0 and "enter"" i have to do it twice to calculate any advice on how to fix the problem?

#include<iostream>

using namespace std ;

int main ()

{
double exchange_rate = 0 ;
double dollar = 0 ;
bool more = true ;

while (more)
{

double input_er ;
cout<< " Please enter U.S dollar to Japanese yen \n exchange rate \n Example 1 dollar is equal to ___ yen \n" ;
cin>> input_er ;

double input_dollar ;
cout<< " Enter the ammount of dollars you wish to convert to yen \n" ;
cout<< " Enter the value 0 to calculate \n" ;
cin>> input_dollar ;

if ( input_dollar == 0)
more = false ;

else
{
exchange_rate = input_er ;
dollar = dollar + input_dollar ;

}

}

if (dollar > 0)
cout<< " You Have " << dollar * exchange_rate << " Yen \n" ;

return 0 ;

}

Is This A Good Question/Topic? 0

## Replies To: Help on exchange rate project

• D.I.C Lover

Reputation: 331
• Posts: 1,168
• Joined: 01-April 11

## Re: Help on exchange rate project

Posted 09 February 2013 - 07:55 PM

Unless the exchange rate is changing between loops (doubtful), I'd ask the dollar to yen exchange rate just once, before the while loop. Otherwise, you'll be prompted for it on every loop.

I would remove the "enter the value 0 to calculate", because it makes no sense. If the user has entered an exchange rate, and they have entered a dollar amount OF COURSE they want to get a calculation.

Also, I would delete the "dollar" variable. You need ONE dollar variable, not two.

It's always a bit clumsy when the program goes into a loop, without confirming the user wants to do that calculation. How about a simple menu, and then the loop runs ONLY when the user enters that menu choice? Just an idea though.

### #3 rrmv951r

Reputation: 1
• Posts: 8
• Joined: 02-February 13

## Re: Help on exchange rate project

Posted 10 February 2013 - 05:42 PM

Adak, on 09 February 2013 - 07:55 PM, said:

Unless the exchange rate is changing between loops (doubtful), I'd ask the dollar to yen exchange rate just once, before the while loop. Otherwise, you'll be prompted for it on every loop.

I would remove the "enter the value 0 to calculate", because it makes no sense. If the user has entered an exchange rate, and they have entered a dollar amount OF COURSE they want to get a calculation. />

Also, I would delete the "dollar" variable. You need ONE dollar variable, not two.

It's always a bit clumsy when the program goes into a loop, without confirming the user wants to do that calculation. How about a simple menu, and then the loop runs ONLY when the user enters that menu choice? Just an idea though.

thanks I took the part where it asks for the exchange rate out of the loop and it works a lot better. Unfortunately am you can see i am an amateur at c++ soo i do not know how to create a menu just yet. I'm sure my coding should get better soon, thanks for the help

• D.I.C Lover

Reputation: 331
• Posts: 1,168
• Joined: 01-April 11

## Re: Help on exchange rate project

Posted 10 February 2013 - 06:58 PM

I don't have a C++ compiler to test it, so tell me, how goes your program?