Complete the C++ skeleton program you have been given. The skeleton contains the
ID: 3728851 • Letter: C
Question
Complete the C++ skeleton program you have been given. The skeleton contains the function declarations, a driver, and empty function definitions. The program currently runs. However, there are several modification you should make for the program to be complete. You will need to implement the empty functions AND make calls to these functions in the main function. Below is a list of the functions you will need to implement: void RepeatDisplay(string st, int num); int SumDigits(int num); string RepeatItem (string st, int num); void StringToFile (string filename, string stuff); void PrintTriangle(int dimension); int CountVowels (string st); Further descriptions of these functions can be found in the in the provided source code file. 12:55 LTE #include #include using namespace std; //constants const string STARS = //Function Prototypes void RepeatDisplay (string st, int num) int SumDigits(int num); string RepeatItem (string st, int num) void StringToFile (string filename, string stuff) void PrintTriangle(int dimension); int CountVowels (string st) int GetChoice(; //Driver Program int main)( int choice = GetChoice(); while ( choice !=0){ system("cls") coutExplanation / Answer
void RepeatDisplay(string st, int num)
{
//loop to display the string at given number of times
for(int i=1;i<=num;i++)
{
cout<<st<<endl;
}
}
int SumDigits(int num)
{
int number = num;
int sum=0;
while (number != 0)
{
sum = sum + number % 10; // get the each digit and add add that into sum
number = number / 10; // truncate the number to get the next digit
}
cout << "The sum of the digits of "<< num << " is " << sum;
}
string RepeatItem (string st, int num)
{
string newStr="";
for(int i=1;i<=num;i++)
{
newStr = newStr+st;
}
return newStr;
}
#include <fstream> // include this header file for file read/wrrite operation
void StringToFile (string filename, string stuff)
{
ofstream myfile (filename);
if (myfile.is_open())
{
myfile << stuff;
myfile.close();
}
else cout << "Unable to open file";
}
void PrintTriangle(int dimension)
{
for(int i = 1; i <= dimension; ++i)
{
for(int j = 1; j <= i; ++j)
{
cout << "* ";
}
cout << " ";
}
}
int CountVowels(string st)
{
int count=0;
for(int i = 0; i<st.length(); ++i)
{
if(st[i]=='a'|| st[i]=='e' | st[i]=='i' || st[i]=='o' || st[i]=='u' || st[i]=='A' || st[i]=='E' || st[i]=='I' || st[i]=='O' || st[i]=='U')
{
++count;
}
}
return count;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.