include <iostream>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int main(void)
{
int num;
char again('Y');
do
{
system("CLS");
cout << "This program will create a pinwheel using the asterisk symbol." << endl
<< "The size of the pinwheel will depend on the user-inputted value." << endl
<< "************************ Let's Start! ************************\n\n"
<< "Please input a number which is <= 39: ";
cin >> num;
for (int i = 1; i <= num; ++i)
{
for (int j = 1; j <= i; ++j)
cout << '*';
for (int k = 1; k <= num - i ; ++k)
cout << ' ';
for (int l = 1; l <= (num + 1) - i; ++l)
cout << '*';
cout << endl;
}
for (int m = 1; m <= num; ++m)
{
for (int k = 1; k <= num - m ; ++k)
cout << ' ';
for (int j = 1; j <= m; ++j)
cout << '*';
for (int l = 1; l <= m - 1; ++l)
cout << ' ';
for (int n = 1; n <= (num + 1) - m; ++n)
cout << '*';
cout << endl;
}
cout << endl << "Do you want to try again? (Y/N): ";
cin >> again;
} while (!(again == 'N' || again == 'n'));
cout<<"Thanks for trying!!";
return 0;
}
I have problems in my Y/N statement. As I enter other variables rather than Y or N, it still acts as 'Y'. How can I make it to display "Invalid input" then have it ask to enter Y or N only.