Need a little help after selecting choice 7 is still asking for size How do I fi
ID: 3646648 • Letter: N
Question
Need a little help after selecting choice 7 is still asking for size How do I fix that?#include <iostream>
#include<iomanip>
using namespace std;
void printLine(int, int);//function prototype
void printTriangle1(int);//function prototype
void printTriangle2(int);//function prototype
void printTriangle3(int);//function prototype
void printTriangle4(int);//function prototype
void printDiagonalUp(int);//function prototype
void printDiagonalDown(int);//function prototype
void main()
{
int line, choice;
do
{
cout << "Shapes Menu" << endl;
cout << "1: Triangle 1" << endl;
cout << "2: Triangle 2" << endl;
cout << "3: Triangle 3" << endl;
cout << "4: Triangle 4" << endl;
cout << "5: Diagonal Up" << endl;
cout << "6: Diagonal Down" << endl;
cout << "7: Quit" << endl;
cout << "Enter choice: ";
cin >> choice;
cout << "Enter size: ";
cin >> line;
if (choice == 1)
printTriangle1(line);
else if (choice == 2)
printTriangle2(line);
else if (choice == 3)
printTriangle3(line);
else if (choice == 4)
printTriangle4(line);
else if (choice == 5)
printDiagonalUp(line);
else if (choice == 6)
printDiagonalDown(line);
else if (choice ==7)
cout << "Goodbye"<<endl;
else
cout << "Invalid Selection. Please Re-enter choice:"<< endl;
}
while(choice!=7);
}//end main
void printLine(int blanks, int stars)
{
int count;
for (count =1; count <= blanks; count++)
{
cout<< ' ';
}
for (count = 1; count <= stars; count++)
{
cout<< '*';
}
cout<< endl;
}
void printTriangle1(int numlines)
{
int numstars;
numstars = 1;
for (int line = 1; line <= numlines; line++)
{
printLine(0, numstars);
numstars = numstars + 1;
}
}
void printTriangle2(int numlines)
{
int numstars;
numstars = numlines;
for (int line = 1; line <= numlines; line++)
{
printLine(0, numstars);
numstars = numstars - 1;
}
}
void printTriangle3(int numlines)
{
int numstars;
numstars = 1;
for (int line = 1; line <= numlines; line++)
{
printLine(numlines - line, numstars);
numstars = numstars + 1;
}
}
void printTriangle4(int numlines)
{
int numstars, blanks = 0;
numstars = numlines;
for (int line = 1 ; line <= numlines; line++)
{
printLine(blanks, numstars);
blanks = blanks++;
numstars = numstars - 1;
}
}
void printDiagonalUp(int numlines)
{
int numstars, blanks;
blanks = numlines - 1;
numstars = 1;
for (int line = 1; line <= numlines; line++)
{
printLine(blanks, numstars);
blanks = blanks--;
}
}
void printDiagonalDown(int numlines)
{
int numstars, blanks;
blanks = 0;
numstars = 1;
for (int line = 1; line <= numlines; line++)
{
printLine(blanks, numstars);
blanks = blanks++;
}
}
Explanation / Answer
its simple just observe the change i have made in if statement #include #includeusing namespace std; void printLine(int, int);//function prototype void printTriangle1(int);//function prototype void printTriangle2(int);//function prototype void printTriangle3(int);//function prototype void printTriangle4(int);//function prototype void printDiagonalUp(int);//function prototype void printDiagonalDown(int);//function prototype void main() { int line, choice; do { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.