Can someone review?

This is a discussion on Can someone review? within the C++ Programming forums, part of the General Programming Boards category; Can someone review this code and tell me what you think about it, does it look correct? Its a code ...

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

    Can someone review?

    Can someone review this code and tell me what you think about it, does it look correct? Its a code for converting foreighn currency



    #include <iostream>
    using namespace std;

    int main()
    {
    //declare constant variables for foreign conversions
    const float swissConvRate = float(.6072);
    const float britConvRate = float(1.4320);
    const float japanConvRate = float(.0081);
    const float canadaConvRate = float(.6556);
    const float euroConvRate = float(.8923);
    //declare constant variables for monetary conversions
    float amerConversion = 0;
    float swissConversion = 0;
    float britConversion = 0;
    float japanConversion = 0;
    float canadaConversion = 0;
    float euroConversion = 0;

    //enter the American dollar amount to be converted
    cout << "Enter the amount in US Dollar: ";
    cin >> amerConversion;

    //calculate conversions from American dollars to foreign monies
    swissConversion = amerConversion/swissConvRate;
    britConversion = amerConversion/britConvRate;
    japanConversion = amerConversion/japanConvRate;
    canadaConversion = amerConversion/canadaConvRate;
    euroConversion = amerConversion/euroConvRate;

    //setting the output to be formatted with two characters after te decimal pt.
    cout << fixed;
    cout.precision(2);

    //display the American dollar value and the 5 foreign conversions
    cout << amerConversion << " US Dollars = " << swissConversion << " Swiss Francs" <<endl;
    cout << amerConversion << " US Dollars = " << britConversion << " British Pounds" <<endl;
    cout << amerConversion << " US Dollars = " << japanConversion << " Japanese Yens" <<endl;
    cout << amerConversion << " US Dollars = " << canadaConversion << " Canadian Dollars"
    <<endl;
    cout << amerConversion << " US Dollars = " << euroConversion << " Euros" <<endl;
    return 0;
    }
    //end of main function

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    fixed in cout << fixed isn't defined.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    Also, I would set the precision of cout higher. Reading scientific notation is frusterating.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Code Review
    By trillianjedi in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 06-18-2008, 12:29 PM
  2. Text Game Review
    By punkrockguy318 in forum Game Programming
    Replies: 16
    Last Post: 10-26-2003, 06:39 AM
  3. My Web site.. Please review..
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 22
    Last Post: 08-11-2003, 08:00 AM
  4. Review a board!
    By Liger86 in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 07-03-2003, 07:43 PM
  5. Exam Review?
    By NinetyFourGirl in forum C++ Programming
    Replies: 4
    Last Post: 06-18-2002, 03:45 PM

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