Begier coder here. I am trying to make a program that can calculated a future day by inputting today and number of days elapsed. For the most part, it works. However, I stumbled upon a tiny problem and I have been stuck with it for the past hour.
`do { cout << "To begin, enter today's day: " << endl << "0. Sunday" << endl << "1. Monday" << endl << "2. Tuesday" << endl << "3. Wednesday" << endl << "4. Thursday" << endl << "5. Friday" << endl << "6. Saturday" << endl; cin >> num1;
while (num1 < 0 || num1 > 6)
{
cout << "The number must be in the range 0 to 6.n";
cout << "Please try again: ";
cin >> num1;
}
cout << "Enter number of days elapsed after today: ";
cin >> numdays;
if (num1 == 0) { today = "Sunday"; }
if (num1 == 1) { today = "Monday"; }
if (num1 == 2) { today = "Tuesday"; }
if (num1 == 3) { today = "Wednesday"; }
if (num1 == 4) { today = "Thursday"; }
if (num1 == 5) { today = "Friday"; }
if (num1 == 6) { today = "Saturday"; }
n = numdays % 7;
switch (n)
{
case 0: cout << "Today is " << today << " and " << num1 << " days from now is Sunday" << endl;
break;
case 1: cout << "Today is " << today << " and " << num1 << " days from now is Monday" << endl;
break;
case 2: cout << "Today is " << today << " and " << num1 << " days from now is Tuesday" << endl;
break;
case 3: cout << "Today is " << today << " and " << num1 << " days from now is Wedday" << endl;
break;
case 4: cout << "Today is " << today << " and " << num1 << " days from now is Thursday" << endl;
break;
case 5: cout << "Today is " << today << " and " << num1 << " days from now is Friday" << endl;
break;
case 6: cout << "Today is " << today << " and " << num1 << " days from now is Saturday" << endl;
break;
default: cout << "Please enter a valid response" << endl;
}
cout << "Press R to try again" << endl; //Prompts the user to try again
cin >> response;
system("cls");
}
while (response == 'R' || response == 'r');
retu 0;`
Here's a part of it. As you can see, my program is supposed to ask the user if he wants to try again. It works for almost everything but the default in the switch, it closes right away instead of asking me if I want to try again. Am I having some sort of misconception or what?
Thanks
