Hello everyone! So I was doing this simple program for my C++ training but there seems to be a error.In the build window doesn`t show any.I will show you right away
#include <iostream.h>
usingnamespace std;
int main ()
{
char Again;
int Day;
cout<<"The day you want is : ";
cin>>Day;
switch (Day)
{
case 1:
{
cout<<"The day you chose is Monday";
break;
}
case 2:
{
cout<<"The day you chose is Tuesday";
break;
}
case 3:
{
cout<<"The day you chose is Wednesday";
break;
}
case 4:
{
cout<<"The day you chose is Thursday";
break;
}
case 5:
{
cout<<"The day you chose is Friday";
break;
}
case 6:
{
cout<<"The day you chose is Saturday";
break;
}
case 7:
{
cout<<"The day you chose is Sunday";
break;
}
default :
{
cout<<"This day number does not exist";
break;
}
}
cout<<"\n";
cout<<"Do you want to choose another day,(y,n)?";
if (Again='y') cin>>Day; //This doesn`t
elseif (Again='n') cout<<"thank you for using our program :)";//show up
return 0;
system ("pause");
}
So in the Build window there is no error ,but in the console when it starts the 'cout' on row 53 and I introduce 'y' or 'n' nothing happens ... just that the program ends doesn`t ask me to introduce the day number again.I really don`t know what I did wrong..Thank you for your time .
Wait, this won't work the way you want it to! At the end, if the user selects y, you'll simply take in a number from the user, and then end the program... You need a while loop to re-run the switch case..