Design a C++ program by considering the following conditions;
1. User must keyed-in “start” to start the program and “stop” to
end the program.
.
2. If the user keyed-in “choice1”, print out PATTERN A.
3. If the user keyed-in “choice2”, print out PATTERN B.
Use if else statement, while loop, nested for loop and switch case statement
in your program.
A B 1 2
C D 3 4
E 5
1 2 A B
3 4 C B
SOL(INCOMPLETE):
#include <iostream>
#include <string>
using namespace std;
int main()
{
char a = 'A';
int choice1, choice2, choice, col, row;
cout << "Enter choise1 for pattern A, or choise2 for pattern B\n";
for (row = 1; row <4; row++){
for (col = 1; col <6; col++){
if (row == col || col == (5 + 1) - row){
cout << a;
a++;
}
else
cout << " ";
}
cout << endl;
}
int x;
x = 1;
for (row = 1; row < 2; row++){
for (col = 1; col < 6; col++){
if (col == row + 1 || col == row + 3){
cout << x;
x++;
}
else
cout << " ";
}
cout << endl;
}
for (row = 1; row < 2; row++){
for (col = 1; col < 6; col++){
if (col == row || col == row + 4){
cout << x ;
x++;
}
else
cout << " ";
}
cout << " \n" <<endl;
}
int y;
y = 1;
char b = 'A';
for (row = 1; row <4; row++){
for (col = 1; col <6; col++){
if (row == col || col == (5 + 1) - row){
cout << y;
y++;
}
else
cout << " ";
}
cout << endl;
}
for (row = 1; row < 2; row++){
for (col = 1; col < 6; col++){
if (col == row + 1 || col == row + 3){
cout << b;
b++;
}
else
cout << " ";
}
cout << endl;
}
for (row = 1; row < 2; row++){
for (col = 1; col < 6; col++){
if (col == row || col == row + 4){
cout << b;
b++;
}
else
cout << " ";
}
cout << endl;
}
cin.get();
return 0;
}