Code:
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
void Sing(){
cout << "Lalala" << endl << endl;
}
void Shout(){
cout << "Ahhhhhh!!!" << endl << endl;
}
int main(){
char ch;
bool bLoop = true;
while(bLoop){
cout << endl << "Enter;" << endl << "1. To Sing" << endl;
cout << "2. To Shout" << endl << "3. To Quit" << endl;
cout << "Then press return" << endl;
cin >> ch;
if(cin.peek() != '\n'){
cout << "Error - 1 digit numer only!" << endl;
while(cin.peek() != '\n')cin.ignore();
continue;
}
switch(ch){
case '1':
Sing();
continue;//The continue statement sends it to the top of the loop
case '2':
Shout();
continue;
case '3':
bLoop = false;
break;
default:
cout << "Wrong selection! Try again" << endl;
continue;
}
}
cout << "That's all folks!" << endl;
return 0;
}