Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 1 BigInt Class structure and test harness* I / Written by S. Gold for CECS 282 Sprint 2019 # include * # include *

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
1 1 BigInt Class structure and test harness* I / Written by S. Gold for CECS 282 Sprint 2019 # include * # include * # include ( Big Int right ) { write Function here ] 1 1 less Than operator* bool operator operator* cout right : It " ; right ) right ) cout right :" The greater of 24 and - 37 is 24 testing int factorial loop : fact ( 8 ) = ] fact ( 1 ) =\\ Fact ( 2 ) fact ( 3 ) = 6\\ Fact ( 4 ) = 24 fact ( 5 ) = 120 fact ( 6 ) = 720 fact ( 7 ) = 5040 fact ( 8 ) = 40320 fact ( 9 ) = 362880 fact ( 10 ) = 362880 0 fact ( 11 ) = 3991680 0 fact ( 12 ) = 47980160 0 fact ( 13 ) = 1932853504 fact ( 14 ) = 1278945280 fact ( 15 ) = 208 4318016 fact ( 16 ) = 2004189184 fact ( 17 ) =\\ - 28852 2 240 fact ( 18 ) = - 89843 3024 fact ( 19 ) = 109641728 fact ( 20 ) = - 2102132736 fact ( 21 ) =\\ - - 11951 14 496 Fact ( 22 ) = - 522715130 fact ( 23 ) = 862453760Fact(24) = -775946246 fact(25) = 2676186486 facttZS) = -1853882368 fact(27) = 1684783616 fact(28) = -1375731712 fact(29) 1241513984 H Largest positive integer: 2147483647 Largest positive long long: 9223372636854775867 testing Biglnt factorial loop: Fact(6) = 1 fact(7) = 5,646 fact(l4) = 87,178,291,266 Fact(21) = 51,696,942,171,769,446,666 Fact(23) = 364,888,344,511,713,866,561,564,666,666 fact(35) = 16,333,147,956,386,144,929,666,651,337,523,266,666,666 fact(42) = 1,465,666,117,752,879,898,543,142,666,254,511,569,936,384,666,666,666 fact(49) = 668,281,864,634,267,566,872,252,163,321,295,376,887,552,831,379,216,246,666,666,666 fact(56) = 716,993,587,864,863,451,85,645,647,463,724,949,736,497,978,881,168,458,687,447,6d6;666,6 66,666,666 fact(63) = 1,982,668,315,464,446,664,116,146,768,361,898,137,544,773,696,227,268,628,166,279,599,612 ,729,753,666,666,666,666,666 fact(7a) = 11,978,5?1,669,969,891,796,672,783,721,689,698,736,458,938,142,5461425,857,555,362,864,62 8,669,582,789,845,319,686,666,666,666,666,666 fact(77) = 145,183,692,628,285,669,634,676,78,686,368,284,983,746,376,224,268,358,366,781,574,688,6 61,991,349,156,426,666,665,267,861,248,666,666,666,666,666,666 fact84) = 3,314,246,134,565,353,266,999,387,579,136,131,288,666,666,286,242,649,487,118,846,632,383 ,659,131,261,716,864,129,885,722,668,716,753,156,177,626,666,666,666,666,666,666 fact(91) = 135,266,152,767,846J296,255,166,568,759,495,142,17,586,866,476,966,677,791,741,734J597,1 53,676,771,559,994,765,685,283,95,756,449,d27,751,168,336,768,668,192,666,666,666,666,66 6,666,666 fact(98) = 9,426,896,448,883,247,745,626,185,743,657,22,473,869,693,764,678,951,663,494,238,777,296 ,767,676,623,223,798,882,976,159,26?,729,119,823,665,856,588,668,466,429,412,647,567,366, 666,666,666,666,666,666,666 How far from the Earth to Pluto ? 291 , 456 , 080 , 080 , 008 inches What is the size of the observable universe ?" 87 , 924 , 571 , 086 , 038 , 400 , 080 , 080 , 008 , 808 millimeters factgg = 933 , 262 , 154 , 439 , 441 , 526 , 816 , 992 , 388 , 562 , 667 , 684 , 987 , 159 , 682 , 643 , 816 , 214 , 685 , 929 , 638 , 952 , 1 75 , 999 , 932 , 299 , 156 , 089 , 414 , 639 , 761 , 565 , 182 , 862 , 536 , 979 , 208 , 272 , 237 , 582 , 511 , 852 , 109 , 168 , 64\\ 8 , 808 , 980 , 090 , 080 , 080 , 000 , 008\\ fact98 = 9 , 426 , 898 , 448 , 883 , 247 , 745 , 626 , 185 , 743 , 857 , 242 , 473 , 809 , 693 , 764 , 078 , 951 , 663 , 494 , 238 , 777 , 294 , 707 , 070 , 023 , 223 , 798 , 882 , 976 , 159 , 207 , 729 , 119 , 823 , 605 , 850 , 588 , 608 , 460 , 429 , 412 , 647 , 567 , 360 , 808 , 808 , 980 , 080 , 080 , 008 , 980 factgg - fact98 =\\ 923 , 835 , 263 , 998 , 558 , 279 , 871 , 356 , 202 , 819 , 609 , 762 , 433 , 349 , 988 , 879 , 737 , 263 , 822 , 435 , 480 , 174 , 8 81 , 292 , 862 , 275 , 932 , 290 , 531 , 663 , 602 , 357 , 453 , 742 , 713 , 373 , 357 , 683 , 629 , 122 , 082 , 439 , 461 , 601 , 28 8 , 808 , 808 , 808 , 808 , 800 , 080 , BOB fact98 - factgg = 923 , 835 , 263 , 990 , 558 , 279 , 071 , 365 , 202 , 819 , 609 , 762 , 433 , 349 , 988 , 879 , 737 , 263 , 822 , 435 , 480 , 174 , 8 81 , 292 , 862 , 275 , 932 , 290 , 531 , 663 , 602 , 357 , 453 , 742 , 713 , 373 , 357 , 683 , 629 , 122 , 082 , 439 , 461 , 601 , 28\\ 8 , 808 , 808 , 080 , 080 , 808 , 680 , BOB ( factgg - fact98 ) + ( fact 98 - fact99 ) = 0 - 508 , 808 is less than - 499 , 999 - 580 , 080 is not greater than - 499 , 999 - 508 , 808 is not equal to - 499 , 999CECS 282-05: C++ for Java Programmers Program 4 BigInt Due: April 9, 2019 (after Spring Break) I like factorials.. . There I've said it. It's a fault of mine, Iknow. But I like them... . However, when I calculate a factorial using recursion in C++, here is the output I get: :ing int factorial loop: _ 2004189184 288522240 898433024 _ 109641728 6 72102132736 24 , 1195114496 120 _ 522715136 720 862453760 5040 , 775946240 40320 2076180480 362880 71853882368 3628800 , 1484783616 39916800 _ 1375731712 479001600 71241513984 1932053504 1278945280 Largest positive integer: 2147483647 2004310016 1. I C) 1 1 1 1 1 1 1 1 1 (l (2 (3 (4 (5 (6 (7 (8 (9 (l (1 (1 (l (1 (1 ??? What is going on???? It looks like things were going well up to fact(12). fact(12) = 479,001,600. However fact( 13) : 6,227,020,800. .. not the output that is displayed above. And then when i get to fact(17), the answer is suddenly negative... I also printed out the largest possible positive integer that C++ provides: 2,147,483,647. That means that I can't even calculate fact(13) on this computer using integers... That's a bummer because I wanted to know how many inches there are between the Earth and Pluto I bet it's more than 2.1 billion... Java has a class called BigInteger, but it's kinda weird... if I want to multiply 2 numbers together, I have to use a function (class method) called \"multiply\" . .. Here is an example: Biglnteger result = new Biqlnteqer(\"0\"); Eiglnteger left = new BigInteger(\"13"); Eiglnteger right = new Biglnteger(\"479001600\"),' result : left.mutliply(right); System.out.println(result); This program will print out 6227020800 the value of fact( 13). Kinda cool... but kinda clunky. I want to be able to code like this: Biglnt result(0), left(13), right(\"479001600\"); result = left * right; cout , +=, -=, *=, operator OOOOOOOO Another requirement is to create a single le for this assignment. You will embed your class in the main program. You will not have separate header and .cpp les for your Biglnt class. As you build your Biglnt, you should create one function and test it before moving to the next one. For example, create the default constructor and test it, then create the operator # include using namespace studi Class BigInt private : Vector storage ;" public :` BigInt ( ) / / default constructor - value should be Of { / / you write this code ) BigInt ( int x ) / / overloaded constructor passing an integer* 1 / / you write this code ) BigInt ( string 5 )\\ 1 / / you write this code ) 1 1 overloaded constructor passing a string Big Int operatort ( BigInt x ) / / addition operator passing BigInt* { / / you write this code ) Big Int operatort ( int * ) / / addition operator passing integer I / / you write this code ) I / this allows you to cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

1 what does yellow colour on the map represent?

Answered: 1 week ago