Question: #include #include #include #include Supercard.h using namespace std; / / Purpose: Introduces the program. / / Requires: Outfile. void printHeading ( ofstream &outfile )
#include
#include
#include
#include "Supercard.h
using namespace std;
Purpose: Introduces the program.
Requires: Outfile.
void printHeadingofstream &outfile;
Purpose: Prints message string as label and the supercard.
Requires: A Supercard and outfile.
void printSuperCardofstream & outfile, string message, Supercard & S;
Purpose: Prints message string as label and the digits of supercard.
Requires: A Supercard and outfile.
void printDigitsofstream& outfile, Supercard& S;
Purpose: Set S to the s complement of S
Requires: Two Supercards S and S
void tensComplementSupercard & S Supercard & S;
Purpose: Sets result to sum of S and S
Requires: Three supercards S S and S
void addSupercardsSupercard & S Supercard & S Supercard & result;
Purpose: Opens file to be written to
void openFilesofstream &outfile;
void printEndMessageofstream & outfile;
Purpose: Thanks the user for running SuperCard Program.
Requires: outfile.
int main
Supercard S S S;
ofstream outfile;
openFilesoutfile;
printHeadingoutfile;
test SetDigit and initialize S
outfile "Initialize S
;
for int i ; i ; i
SsetDigiti i;
for int i ; i ; i
SsetDigiti;
test length
outfile "The length of S is SgetLength endl;
output value of S
printSuperCardoutfileS S;
swap S and S and print S
outfile "Swap S and s endl;
SswapS;
printSuperCardoutfileS S;
clear S and reset it to and ouput value of S
outfile "Reset S to
;
Sclear;
for int i ; i ; i
SsetDigiti i;
printSuperCardoutfileS S;
test get digit and compute s complement of S
outfile "Let S be the s complement of S
;
tensComplementS S;
output the new value of S
printSuperCardoutfileS S;
add S and S store in S and print it
addSupercardsS S S;
printSuperCardoutfile "Sum of S and S is S;
test destructor
outfile"Getting ready to destruct S and S
;
printEndMessageoutfile;
return ;
void openFilesofstream &outfile
opens file to be written to
outfile.openSCOuttxt;
void printHeadingofstream & outfile
outfile "Catherine Stringfellow" endl
"Program : Program will process big numbers." endl endl;
void printEndMessageofstream & outfile
outfile "Thank you for using the SuperCard Program.
;
outfile If your program does not crash destructor worked.
;
outfile "Goodbye." endl;
void printSuperCardofstream & outfile, string message, Supercard & S
print the message
reset the cursor
call the function printDigits below
This is a recursive function to print the digits in reverse
void printDigitsofstream& outfile, Supercard& S
void tensComplementSupercard & S Supercard & S
clear S
set each digit of S to the corresponding digit in S
void addSupercardsSupercard & S Supercard & S Supercard & result
clear result
declare variables needed
while more digits in either S or S keep adding digits
get digit from S if none set digit to
get digit from S if none set digit to
sum digits and compute carry
set sum to just the one's digit
set the proper digit in result
update pos
take care of last carry if
complete the code based on the skeleton instructions the comments in the skeleton code no vectors, no :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
