By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Currency Conversion using OO

P: n/a
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?

Oct 11 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"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.
Oct 11 '05 #2

P: n/a
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
Oct 11 '05 #3

P: n/a
In article <3r************@individual.net>,
osmium <r1********@comcast.net> 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?
Oct 11 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.