I'm a bit new to coding and taking a beginner course in C++ coding. My instructor has given me a an assignment asking for me to write a while loop checking for upper and lower case variables. I feel like it is a simple thing to write and I've researched some help on the topic, but I can't seem to make it work yet. I've emailed my instructor, but he hasn't replied, so I am posting here to hopefully get some new perspective.
Here is the code he provided:
// PLACE YOUR NAME HERE
#include <iostream>
using namespace std;
int main()
{
char doneYet = 'N'; // on the 2nd run comment this and uncomment the next line
//char doneYet = 'Y';
// Set this while loop to run as long as doneYet is ‘N’ or ‘n’
while() // Make sure to check for BOTH upper and lowercase!
{
cout << "Am I done yet? (Y/N)\n";
cin >> doneYet;
}
system("pause");
return 0;
}
His request is "Type in the program above and run it. Answer ‘y’ after the first run. Now modify the program comments so that doneYet is ‘y’ and run it. What happens? Based on this experiment, what is the MINIMUM number of times a while loop can run?"
So far I have this as my code:
// PLACE YOUR NAME HERE
#include <iostream>
using namespace std;
int main()
{
char doneYet = 'N'; // on the 2nd run comment this and uncomment the next line
//char doneYet = 'Y';
// Set this while loop to run as long as doneYet is ‘N’ or ‘n’
while( doneYet = 'N') // Make sure to check for BOTH upper and lowercase!
{
cout << "Am I done yet? (Y/N)\n";
cin >> doneYet;
}
system("pause");
return 0;
}
It will now prompt for input from the user. But whatever I enter, whether it is a n, N, y, Y or any other number or letter, it just repeats the loop and asks again. I believe my instructor is asking for the program to end if y or Y is not entered. I'm sure it's just a simple task, but a little more input would be great. Thank you for your time.