To Log Everything I find useful. If you find anything inappropriate, please contact cuijinqiang@gmail.com
Wednesday, August 29, 2012
Switch
#include "iostream"
#include "iomanip"
using namespace std;
void main()
{
// Code 3, test switch fuction
bool quit = false;
char response;
cout << "Please input a, b, c,or q" << endl;
cin >> response;
while(quit == false)
{
cin >> response;
switch(response)
{
case 'a': cout <<"You chose 'a'" << setw(3) << endl; break;
case 'b': cout <<"You chose 'b'" << setw(3) << endl; break;
case 'c': cout <<"You chose 'c'" << setw(3) << endl; break;
case 'q': cout <<"You chose 'q', Program Will quit" << setw(3) << endl; quit = true; break;
default : cout <<"Please choose only a b c q" << endl;
}
};
while (getchar())
{
if (getchar()) break;
}///
//return 0;
}
Labels:
Cpp
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment