Some Help Needed!

This is a discussion on Some Help Needed! within the C++ Programming forums, part of the General Programming Boards category; I have written code to convert foreign currency into US dollars. Now I am trying to write code for a ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    15

    Some Help Needed!

    I have written code to convert foreign currency into US dollars. Now I am trying to write code for a menu (display using loop) that allows the user to choose which currency and the amount of the foreign currency they wish to convert to US dollars. I am using Function(s) must be used. Below is what I have so far!

    #include<iostream.h>

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

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

    cout<<"--------------------\n";

    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
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Use void commands...

    Code:
    #include <iostream.h>
    #include <conio.h>
    
    void menu();
    void US2YEN();
    
    float amount;
    int choice;
    
    int main()
    {
         cout<<"Welcome to my converter!"<<endl;
         cin.get();
         menu();  //after enter is hit go to menu func.
         
         return 0;
    }
    
    void menu()
    {
         cout << " Menu"<<endl;
         cout << "_________"<<endl<<endl;
         cout << "     1) Us to Yen"<<endl<<endl;
          
         cout << "Make your choice: "; cin >>choice;
    
                 if( choice == 1) US2YEN();
                 else{ 
                     clrscr();
                     menu();
                 }
    }
    
    void US2YEN()
    {
        // CODE HERE
    }
    yah its kinda rough... if you cant understand tell me
    What is C++?

  3. #3
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    I am not that good of a coder, but I will try. By the way if this is a school assignment, you are missing out on learning by having other people do it.

    Code:
    #include <iostream>
    
    #define FRANCS 0.6072
    #define POUNDS 1.4320
    #define YEN 0.0081
    #define CDOLLARS 0.6556
    #define EUROS 0.8923
    
      using namespace std;
    
      int menu();
      void convertmoney(int amount, double type);
    
    int main()
    {
      int money;
      cout << "How much money to convert? ";
      cin >> money;
    
      int menuchoice;
      menuchoice = menu();
    
      switch(menuchoice)
      {
        case 1:
          convertmoney(money, FRANCS);
        break;
        case 2:
          convertmoney(money, POUNDS);
          break;
        case 3:
          convertmoney(money, YEN);
          break;
        case 4:
          convertmoney(money, CDOLLARS);
          break;
        case 5:
          convertmoney(money, EUROS);
          break;
        default:
          return 0;
          break;
      }
    }
    
    int menu()
    {
      cout << "Convert to what currency?" << endl;
      cout << "[1] - Swiss Francs" << endl;
      cout << "[2] - British Pounds" << endl;
      cout << "[3] - Japanese Yen" << endl;
      cout << "[4] - Canadian Dollars" << endl;
      cout << "[5] - Euros" << endl;
    
      int temp;
      cin >> temp;
    
      return temp;
    }
    
    void convertmoney(int amount, double type)
    {
      cout << "The amount is " << amount/type << endl;
    }

  4. #4
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    And so it came to pass another student got his homework done for him
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    15
    I really appreciate your help!

  6. #6
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    Oh well, when he gets a test in class he will fail. Or when his teacher ask him how the code works. He only hurts himself by asking, and I like coding little stuff.

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Ahhh... Then your code may be interpreted as a form of punishment? Excellent! I was afraid for a brief moment that our little pest was being rewarded for ignoring virtually every guideline this forum has.

    (I think I hear a collective pounding of heads on the table. Easy, Mario!!)


    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  8. #8
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    LOL!

    Dang! Have to switch my webcam off
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 10:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 12:55 PM
  3. lock needed in this scenario?
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-25-2008, 08:22 AM
  4. Releasing a program - what is needed? A few Q's
    By ulillillia in forum Tech Board
    Replies: 9
    Last Post: 04-28-2007, 01:18 AM
  5. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-01-2004, 12:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21