Connecting Tech Pros Worldwide Forums | Help | Site Map

Currency Conversion using OO

Willing 2 Learn
Guest
 
Posts: n/a
#1: Oct 11 '05
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?




osmium
Guest
 
Posts: n/a
#2: Oct 11 '05

re: Currency Conversion using OO


"Willing 2 Learn" writes:
[color=blue]
> 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.[/color]

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.
[color=blue]
> 2) Also, do u have any idea how to do dot product, scalar product,
> magnitude, direction operations on a vector using OO?[/color]

Yes.


Victor Bazarov
Guest
 
Posts: n/a
#3: Oct 11 '05

re: Currency Conversion using OO


Willing 2 Learn wrote:[color=blue]
> 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.[/color]

Help you, how?
[color=blue]
> 2) Also, do u have any idea how to do dot product, scalar product,
> magnitude, direction operations on a vector using OO?[/color]

Yes, I do.

V
Greg Comeau
Guest
 
Posts: n/a
#4: Oct 11 '05

re: Currency Conversion using OO


In article <3r278tFhjtorU1@individual.net>,
osmium <r124c4u102@comcast.net> wrote:[color=blue]
>"Willing 2 Learn" writes:
>[color=green]
>> 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.[/color]
>
>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.[/color]

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?
Closed Thread


Similar C / C++ bytes