Currency Conversion using OO

Discussion in 'C++' started by Willing 2 Learn, Oct 11, 2005.

  1. I'm trying to learn how to use C++, the OO way. I need help with a
    simple program im doing to convert currency by creating a class for
    this ADT. I know it should have a header file, main program,program
    with functions, Constructor with arguments; default constructor with no
    arguments;add, subtract, scalar multiply;show. Also I want it to show
    all the #'s in cents and not round to 2 decimal places. I am struggling
    to see how to use all 3 of these to convert cents to dollars and vice
    versa. I already have 2 variables dollars & cents & im thinking i need
    to convert both to a single variable then do the math. After this point
    im stuck. Could you help me please, I would be very grateful.

    2) Also, do u have any idea how to do dot product, scalar product,
    magnitude, direction operations on a vector using OO?
     
    Willing 2 Learn, Oct 11, 2005
    #1
    1. Advertising

  2. Willing 2 Learn wrote:
    > I'm trying to learn how to use C++, the OO way. I need help with a
    > simple program im doing to convert currency by creating a class for
    > this ADT. I know it should have a header file, main program,program
    > with functions, Constructor with arguments; default constructor with no
    > arguments;add, subtract, scalar multiply;show. Also I want it to show
    > all the #'s in cents and not round to 2 decimal places. I am struggling
    > to see how to use all 3 of these to convert cents to dollars and vice
    > versa. I already have 2 variables dollars & cents & im thinking i need
    > to convert both to a single variable then do the math. After this point
    > im stuck. Could you help me please, I would be very grateful.


    Help you, how?

    > 2) Also, do u have any idea how to do dot product, scalar product,
    > magnitude, direction operations on a vector using OO?


    Yes, I do.

    V
     
    Victor Bazarov, Oct 11, 2005
    #2
    1. Advertising

  3. Willing 2 Learn

    osmium Guest

    "Willing 2 Learn" writes:

    > I'm trying to learn how to use C++, the OO way. I need help with a
    > simple program im doing to convert currency by creating a class for
    > this ADT. I know it should have a header file, main program,program
    > with functions, Constructor with arguments; default constructor with no
    > arguments;add, subtract, scalar multiply;show. Also I want it to show
    > all the #'s in cents and not round to 2 decimal places. I am struggling
    > to see how to use all 3 of these to convert cents to dollars and vice
    > versa. I already have 2 variables dollars & cents & im thinking i need
    > to convert both to a single variable then do the math. After this point
    > im stuck. Could you help me please, I would be very grateful.


    The class should have only one datum:

    long cents;

    Convert as necessary, both input and output. The long might be a problem in
    a real program (too small) but it is OK to use in learning the
    fundamentals.

    > 2) Also, do u have any idea how to do dot product, scalar product,
    > magnitude, direction operations on a vector using OO?


    Yes.
     
    osmium, Oct 11, 2005
    #3
  4. Willing 2 Learn

    Greg Comeau Guest

    In article <>,
    osmium <> wrote:
    >"Willing 2 Learn" writes:
    >
    >> I'm trying to learn how to use C++, the OO way. I need help with a
    >> simple program im doing to convert currency by creating a class for
    >> this ADT. I know it should have a header file, main program,program
    >> with functions, Constructor with arguments; default constructor with no
    >> arguments;add, subtract, scalar multiply;show. Also I want it to show
    >> all the #'s in cents and not round to 2 decimal places. I am struggling
    >> to see how to use all 3 of these to convert cents to dollars and vice
    >> versa. I already have 2 variables dollars & cents & im thinking i need
    >> to convert both to a single variable then do the math. After this point
    >> im stuck. Could you help me please, I would be very grateful.

    >
    >The class should have only one datum:
    >
    >long cents;
    >
    >Convert as necessary, both input and output. The long might be a problem in
    >a real program (too small) but it is OK to use in learning the
    >fundamentals.


    Also, don't know the OP motivation, but have a look at the
    numeric and money capabilities found in <locale>
    --
    Greg Comeau / Celebrating 20 years of Comeauity!
    Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
    World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
    Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
     
    Greg Comeau, Oct 11, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martyn Fewtrell

    String (Currency) to Decimal Conversion

    Martyn Fewtrell, Jun 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    4,202
    Martyn Fewtrell
    Jun 21, 2005
  2. Just starting out

    Currency conversion program

    Just starting out, Sep 5, 2005, in forum: C Programming
    Replies:
    14
    Views:
    827
    Gordon Burditt
    Sep 12, 2005
  3. Willing 2 Learn

    Currency Conversion using OO

    Willing 2 Learn, Oct 12, 2005, in forum: C++
    Replies:
    2
    Views:
    547
    Bob Hairgrove
    Oct 12, 2005
  4. Willing 2 Learn

    Currency Conversion using OO

    Willing 2 Learn, Oct 12, 2005, in forum: C++
    Replies:
    0
    Views:
    288
    Willing 2 Learn
    Oct 12, 2005
  5. powerranger

    currency conversion webservice

    powerranger, Jan 25, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    120
    Jan Tielens
    Jan 26, 2004
Loading...

Share This Page