Click to See Complete Forum and Search --> : calculator
John C
08-15-2001, 07:49 PM
ok can anyone give me a calculator program which takes or inputs either one
or two real numbers, depending on the choice of operation:
- arithmetic: +, -, /, *
- exponent: a to the b power where b is an integer (positive, negative, or
0) carefule 0 to the 0 power is undefined
- square root: use sqrt in <math.h> but don't take the sqrt of a negative
#
> you must write a function for atleast the exponential and square root operations.
> your program should loop until the user chooses to quit.
"John C" <desideus@hotmail.com> wrote:
>
>ok can anyone give me a calculator program which takes or inputs either
one
>or two real numbers, depending on the choice of operation:
>
>- arithmetic: +, -, /, *
>- exponent: a to the b power where b is an integer (positive, negative,
or
>0) carefule 0 to the 0 power is undefined
>- square root: use sqrt in <math.h> but don't take the sqrt of a negative
>#
>
>> you must write a function for atleast the exponential and square root
operations.
>> your program should loop until the user chooses to quit.
Please, see the excelent article by Bartosz Milewski on Polymorphism at InformIt.com
website. He shows how to design a calculator taking full advantage of the
power of polymorphism. I think it's a good start for begin building the application
you want. The url is:
http://www.informit.com/topics/index.asp?n={0F8B3974-A932-4FFE-9DF6-96887E6F9AA7}&t={6373D50E-EF0B-4084-B8A7-032653E262E2}
In this page, click over the link regarding to the article "Polymorphism
in C++"
Hope this helps.
Luis
Christopher Thomas McGinlay
08-16-2001, 12:12 PM
Stroustrup's book develops a nice calculator over several chapters of
his book "The C++ Programming Language". It uses recursive descent to
parse an arithmetic expression.
Chris
John C wrote:
> ok can anyone give me a calculator program which takes or inputs either one
> or two real numbers, depending on the choice of operation:
>
> - arithmetic: +, -, /, *
> - exponent: a to the b power where b is an integer (positive, negative, or
> 0) carefule 0 to the 0 power is undefined
> - square root: use sqrt in <math.h> but don't take the sqrt of a negative
> #
>
>
>> you must write a function for atleast the exponential and square root operations.
>> your program should loop until the user chooses to quit.
--
Ascent Software Limited Registered in Scotland: SC201671
www.ascent.zetnet.co.uk Bank Of Scotland Buildings
Lerwick, Shetland, ZE1 0EB
devx.com
Copyright Internet.com Inc. All Rights Reserved