Connecting Tech Pros Worldwide Help | Site Map

Currency Conversion using OO

 
LinkBack Thread Tools Search this Thread
  #1  
Old October 11th, 2005, 04:25 PM
Willing 2 Learn
Guest
 
Posts: n/a
Default Currency Conversion using OO

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?


  #2  
Old October 11th, 2005, 04:35 PM
osmium
Guest
 
Posts: n/a
Default 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.


  #3  
Old October 11th, 2005, 04:35 PM
Victor Bazarov
Guest
 
Posts: n/a
Default 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
  #4  
Old October 11th, 2005, 05:15 PM
Greg Comeau
Guest
 
Posts: n/a
Default 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?
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.