Upload
bishoy-emile
View
213
Download
0
Embed Size (px)
DESCRIPTION
project
Citation preview
Object Oriented Programming
Implement a class BigInt to handle big integers more than what primitive integer data type can handle. The BigInt class has the following properties:
1. String Num: to store the number in it. 2. Define two variables, BigInt remainder , BigInt: quotient 3. Default constructor : BigInt ()4. Constructor with parameters : BigInt(string s), 5. Copty constructor BigInt(const BigInt & bi),
6. Virtual Overloading of +operator to Add two BigInt Numbers: virtual BigInt operator+ (const BigInt& arg);
7. Virtual Overloading of -operator to subtract two BigInt Numbers: virtual BigInt operator-(const BigInt& arg);
8. Virtual Overloading of *operator to multiply two BigInt Numbers: virtual BigInt operator* (const BigInt& arg);
9. Virtual Overloading of / operator to Divide two BigInt Numbers: virtual BigInt operator/ (const BigInt& arg);
10. Virtual Overloading of == operator to compare two BigInt Numbers: virtual bool operator ==(const BigInt& arg);
11. Virtual Overloading of << operator to print a BigInt : virtual ostream& operator<< (ostream& os, const BigInt& arg)
12. Virtual Overloading of >> operator to read a BigInt : virtual istream& operator>> (istream& os, const BigInt& arg);
Extend the BigInt class by BigComplex class and add the following properties1. String iNum: to store the imaginary part of a complex number. 2. Default constructor : BigComplex ()3. Constructor with parameters : BigComplex (string real, string imag), 4. Copty constructor BigComplex(const BigComplex & arg),5. Overwrite functions from point 6 to 10 to perform (+,-,*,/) mathematical and comparison operations on two
BigComplex objects; you may define two variables numerator of type BigComplex and denominator of type BigInt to store the return result of division operation.
6. Overwrite functions from point 11 to 12 to work on BigComplex class.
Write a main function that tests all functions in both BigInt and BigComplex classes. You can add any functions and code to implement the requirements.
For testing
47863784364786347364437463666666666666666666667888888888888837436487348376434624732463746346346374637464372388888888888888888888888888888888888888888888747377737373773737739723872893238273823928382372989372888888888888888888999999999999933333333333333000000000000033823723727863987273273268+83746347634783647364736473643743743473747434646466464643848348384388746734736473434736734377777777434343747473477377347777777777777777777343473743737473636646343837637463894343637374663746374673467346374634343434
= 47863784364786347364437463666666666666666666667888888888888837436487348376434708478811381129993739373938016132632362636323535355353532737237273277635623483851172110508115517501307236985747301305730150767150666666666232362632737473636646277170970797227343637374663780198397195210361907616702 =================================================================X = 834853478563475647534785645745467546785647856487564785648576478564756475647856456475647856478564875647865467546756478564564785647865475646547576457846574574658475634754658475485457468576464546547854687564756478564785647547563Y = 9845748574897549857345678478545786457864747747574747747474774747474777477477585868866969797979994838383828288848848548578478875848458475858454854888874857945845748758948475847589458947857489589454854758475984758945487589484854787858485848548581
X-Y = -9845748574897549856510824999982310810329962101829280200689126890987212691829009390302213322332138381908180432370283672930613408301701997293890069241009382299298172301101901272930983313102831113969397289899520212397632901920098309293700201001018 =======================================================================478637843647863473644374636666666666666666666678888888888888374364873483764347084788113811299937393739380161326323626363235353553535327372372732776356234838511721105081155175013072369857473013057301507671506666666662323626327374736366462771709707972273436*4786378436478634736443746366666666666666666666788888888888883743648734837643470847881138112999373937393801613263236263632353535535353273723727327763562348385117211050811551750130723698574730130573015076715066666666623236263273747363664627717097=2290941853718766005869887308386393961298449590576653806225028368144209029096119488197340644970035945317437389740163622491638136967567140225803016740948917724531383173062012718690674173155571012438799438910670340920293563940797879331191748081071524906458206083364495846604455317610263396463624795289323319817430025874242977331577971760625005980274509517451156330750766471334685429674103701813550330076702655393116903430647914168584534623329694906926315340497319878727057802474060505153902741736135292 ===============================================================85647564785643687463744684535874654756487634746348736577777777777777777777777777789345847654785454768785784564875647547564757747568475674654785478568584756464785745465874657846584785467475487547885475467454567777777777777748544834838447856474574567456475478547547854785478564875895748574895478954
/ 48754785467854657478546784564875764574564785457
Quotient = 1756700680020701404391983560542981416851567102164777494262675734108147881410036955418917372581579040176910832760138936555956012478493862758579842798187191004564783079952337241716014320740587369188197843524091592570620730425932404472933240241924429746Remainder = 6305117842137298975600274754671050757336475032
Illustrations of Operations on complex numbers
To add and subtract complex numbers: Simply combine like terms. For example, (3 – 2i) – (2 – 6i) = 3 – 2i – 2 + 6i = 1 + 4i.
To multiply two complex numbers: Example: (3 – 2i)*(9 + 4i) = 27 + 12i – 18i – 8i2, which is the same as 27 – 6i – 8(–1), or 35 – 6i.
To divide complex numbers: Multiply both the numerator and the denominator by the conjugate of the denominator and then
combine like terms.
For example, say you're asked to divide
The complex conjugate of 3 – 4i is 3 + 4i. Follow these steps to finish the problem:
1. Multiply the numerator and the denominator by the conjugate.
Numerator: (1 + 2i)(3 + 4i) = 3 + 4i + 6i + 8i2, which simplifies to (3 – 8) + (4i + 6i), or –5 + 10i.
Denominator (3 – 4i)(3 + 4i) = 9 + 12i – 12i – 16i2 =25 , Because i2 = –1 and 12i – 12i = 0,
2. Rewrite the numerator and the denominator.