Money Conversion

This is a discussion on Money Conversion within the C++ Programming forums, part of the General Programming Boards category; In one of the excercieses that i'm doing it wan'ts me to write a program that asks the user to ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    38

    Money Conversion

    In one of the excercieses that i'm doing it wan'ts me to write a program that asks the user to input an amount in dollars (5.67) and then converts that (5.67) to the old british style system of pounds shilling and pence (10.3.9). Here's some info

    20 shilling = 1 pound
    12 pence (pennies) = 1 shilling
    240 pence (pennies) = 1 pound

    interaction with the program might look like this:

    //example
    Enter amount in new style currency: 5.67 //example
    Converted (pound, shilling, pence) = 10.3.9 //not right answer

    I'm very confused on how to go about converting this. This is all the info that's given. If you have any suggestions plz write back. thanks

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    / operator for integer division quotient.
    % operator for integer division remainder.

    all floting point values can be turned into integers with some creative maths

    example...
    Code:
    int a = 25;
    int quotient = a / 7;
    int remainder = a % 7;
    should have some clue now!
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    38
    ummm..acually i dont' have any clue. Hey stoned coder. Man, it seemed like your always on. Your the first one the answer each of my question most of the time thanks. But, what you wrote didn't seem to strike a bell
    #include <Jesus.h>
    It will save your life

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    in the mythical world of cprog the currency is the salem. There are 5 fordys to the salem and 10 volks to the fordy.
    Code:
    #include<iostream>
    using namespace std; // for ease of my typing.U do the right thing.read faq namespace tut.
    
    int main()
    {
    int total;
    cout<<"Enter amount of volks....";
    cin>>total;
    int salems = total/50;
    int remainder = total%50;
    int fordys = remainder/10;
    remainder %= 10;
    cout<<endl<<"that is "<<salems<<" salems and "<<fordys<<" fordys and "<<remainder<<" volks"<<endl;
    return 0;
    }
    Work out how that works and you will be on your way.
    Last edited by Stoned_Coder; 03-25-2003 at 09:58 PM.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Registered User
    Join Date
    Feb 2003
    Posts
    595
    You will also need an exchange rate, i.e. how many pounds to the dollar. Since the actual exchange rate varies from day to day, consider prompting the user to input that. You can find the current rate at sites like this one:

    http://www.xe.com/ucc/

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >There are 5 fordys to the salem and 10 volks to the fordy.
    What about the prelude? All I have are volks and they jingle too much. Of course, if I get more than 6 or 7 preludes to the fordy then they'll jingle too much too. We need a good table of exchange rates, do you have one handy?

    p.s. I really would like some quzahs too, I have no doubt that the face of the coin is . Those would be fun to have.

    -Prelude
    My best code is written with the delete key.

  7. #7
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    those currencies are in common usage in cprog as u well know but they would have bloated the example so were left out for brevity....

    My apologies to the forgotten
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  8. #8
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Wow, is it really 5 fordys to the salem nowadays? Jeez I hate inflation. I remember back in the days when when one could get a whole cheeseburger and a cherry coke for only a volk and still have plenty of quzahs left over. Ahhh, the good ol' days.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  4. Do I have a scanf problem?
    By AQWst in forum C Programming
    Replies: 2
    Last Post: 11-26-2004, 06:18 PM
  5. Money classs
    By blackjs in forum C++ Programming
    Replies: 5
    Last Post: 12-04-2001, 10:43 AM

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