how to write a program in c++ to convert currency?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ennie malebati
    New Member
    • Aug 2010
    • 1

    how to write a program in c++ to convert currency?

    can u please help me to write a progam that convert one currency to another?
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    We can help but we can't write it from scratch.

    Comment

    • Oralloy
      Recognized Expert Contributor
      • Jun 2010
      • 988

      #3
      Some days you just have to respond ....

      Code:
      main()
      {
        float dollars;
        int want;
      
        printf("Input dollars: ");
        cin >> dollars;
        if (0. == dollars)
        {
          printf("give nothing, get nothing...\n");
          exit(1);
        }
        else if (0. > dollars)
        {
          printf("I wrote input, not take!\n");
          exit(2);
        }
        else if (1. > dollars)
        {
          printf("Well, you sure are a parsimonious one, aren't you?\n");
          exit(3);
        }
        else
        { }
      
        printf("What do you want in return: 1 dollars, 2 nothing? ");
        cin >> want;
      
        if (1 == want)
          printf("Sure thing, here's your $%f.2 back, less my fee, of course.", (dollars - 0.50));
        else if (2 == want)
          printf("Here you go ... a whole lot of nothing ...\n");
        else
          printf("I guess you're sure ... here's your %d back.  I'll keep the $%f.2 for the effort.", desire, dollars);
      
        return 0;
      }

      Comment

      • whodgson
        Contributor
        • Jan 2007
        • 542

        #4
        Do you have a list of exchange rates?
        If not they will be in your local newspaper or Google.
        Can you convert one currency to another using exchange rates and a pencil and paper? Write out the mechanism and then convert it to C++.
        e.g. if 1.0 $A=1.68$Fiji
        and 1.0 $A=6.8$HK
        then 1.68$F=6.8$HK
        or 1.0 $Fiji = 6.8/1.68 = 4.05$HK
        You could use the switch and case: construction for these conversion constants.
        If you post some code and say where you are having difficulties someone will help you.

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          Some websites provide open access to text files containing exchange rate data.

          These can be opened and parsed to get the data you require.
          Most actually charge, but a free one is Timegenie.

          Comment

          Working...