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 printHeading(ofstream &outfile);
//Purpose: Prints message (string) as label and the supercard.
//Requires: A Supercard and outfile.
void printSuperCard(ofstream & outfile, string message, Supercard & S);
//Purpose: Prints message (string) as label and the digits of supercard.
//Requires: A Supercard and outfile.
void printDigits(ofstream& outfile, Supercard& S);
//Purpose: Set S1 to the 10s complement of S2
//Requires: Two Supercards S1 and S2
void tensComplement(Supercard & S1, Supercard & S2);
//Purpose: Sets result to sum of S1 and S2
//Requires: Three supercards S1, S2, and S3
void addSupercards(Supercard & S1, Supercard & S2, Supercard & result);
//Purpose: Opens file to be written to.
void openFiles(ofstream &outfile);
void printEndMessage(ofstream & outfile);
//Purpose: Thanks the user for running SuperCard Program.
//Requires: outfile.
int main()
{
Supercard S1, S2, S3;
ofstream outfile;
openFiles(outfile);
printHeading(outfile);
//test SetDigit and initialize S1
outfile << "Initialize S1
";
for (int i =1; i <=9; i++)
S1.setDigit(i, i);
for (int i =10; i <=14; i++)
S1.setDigit(i,0);
//test length
outfile << "The length of S1 is "<< S1.getLength()<< endl;
//output value of S1
printSuperCard(outfile,"S1=", S1);
//swap S1 and S2 and print S2
outfile << "Swap S1 and s2"<< endl;
S1.swap(S2);
printSuperCard(outfile,"S2=", S2);
//clear S2 and reset it to 987654321 and ouput value of S2
outfile << "Reset S2 to 987654321
";
S2.clear();
for (int i =1; i <=9; i++)
S2.setDigit(i, i);
printSuperCard(outfile,"S2=", S2);
//test get digit and compute 10's complement of S2
outfile << "Let S1 be the 10's complement of S2
";
tensComplement(S1, S2);
//output the new value of S1
printSuperCard(outfile,"S1=", S1);
//add S1 and S2, store in S3 and print it
addSupercards(S1, S2, S3);
printSuperCard(outfile, "Sum of S1 and S2 is ", S3);
//test destructor
outfile<<"Getting ready to destruct S1 and S2.
";
printEndMessage(outfile);
return 0;
}
void openFiles(ofstream &outfile)
{
//opens file to be written to.
outfile.open("SCOut.txt");
}
void printHeading(ofstream & outfile)
{
outfile << "Catherine Stringfellow" << endl
<< "Program 5: Program will process big numbers." << endl << endl;
}
void printEndMessage(ofstream & outfile)
{
outfile << "Thank you for using the SuperCard Program.
";
outfile <<"If your program does not crash - destructor worked.
";
outfile << "Goodbye." << endl;
}
void printSuperCard(ofstream & 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 printDigits(ofstream& outfile, Supercard& S)
{
}
void tensComplement(Supercard & S1, Supercard & S2)
{
//clear S1
//set each digit of S1 to 10- the corresponding digit in S2
}
void addSupercards(Supercard & S1, Supercard & S2, Supercard & result)
{
//clear result
//declare variables needed
//while more digits in either S1 or S2, keep adding digits
//get digit from S1, if none set digit to 0
//get digit from S2, if none set digit to 0
//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 1
}
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!