Thread: C++ Question

  1. #1
    Registered User
    Join Date
    May 2002

    C++ Question

    I am trying to expand on a currency conversion code that I wrote I'm tryin to create a menu (using a loop) that allows the user to choose which currency and the amount of the foreign currency they wish to convert to US dollars. The program will continue running u.ntil the user select "Exit" option. Below is the code I been done so far


    double amount = 0.0; /*Stores user input*/

    int main()
    cout<<"Currency Conversion"<<endl;


    cout<<"Enter the amount in US Dollar: "; /*Prompt user for amount*/

    cin>>amount; /* Read in the amount*/

    /*Convert the amount to each currency type and print it out*/

    cout<<amount<<" US Dollars = "<<amount/0.6072<<" Swiss Francs\n";
    cout<<amount<<" US Dollars = "<<amount/1.4320<<" British Pounds\n";
    cout<<amount<<" US Dollars = "<<amount/0.0081<<" Japanese Yens\n";
    cout<<amount<<" US Dollars = "<<amount/0.6556<<" Canadian Dollars\n";
    cout<<amount<<" US Dollars = "<<amount/0.8923<<" Euros\n";


  2. #2
    Registered User Liam Battle's Avatar
    Join Date
    Jan 2002
    so what are you asking ?
    how to write a loop?

    also note the global variable i see, omg please dont use that !
    LB0: * Life once school is done
    LB1: N <- WakeUp;
    LB2: N <- C++_Code;
    LB3: N >= Tired : N <- Sleep;
    LB4: JMP*-3;

  3. #3
    Registered User
    Join Date
    Jun 2002
    A loop.. so:
    int menu()
      int x;
      cout << "What do you want?";
      cout << "1 - exit\n" << "2 - continue"<< endl;
      cin >> x;
      return (x - 1);
    int main(void)
    while (menu()) {
       // do something, your conversion for example
      return 0;
    You can use do-while loop instead of while..
    Maybe there are some bugs, but I don't have time to debug it.

  4. #4
    Registered User
    Join Date
    Apr 2002

    MAZO did it...

    I think that was the right way,,,
    good job MAZO
    The best

  5. #5
    Registered User
    Join Date
    Dec 2001



    ob1cnobe: how many times have you posted this SAME post to this board?! I've seen it in quite a few different threads!

    The reason you're not getting help is because you're not trying to do things yourself, and you're not really asking a question!!!

    If you READ the other threads, and follow people's advice, you may just get better responses from people!

    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM