Switch- How to benefit from the remaining cases

posted Jan 28, 2013, 2:46 AM by Karwan Jacksi   [ updated Jan 28, 2013, 2:46 AM ]
#include <iostream>

using namespace std;


void main()
{
int modelNum;
 // Display available models and get the user's choice
 cout << "Our TVs come in three models:\n";
 cout << "The 100, 200, and 300. Which do you want? ";
 cin >> modelNum;

 // Display the features of the selected model
 cout << "That model has the following features:\n";
 switch (modelNum)
 {
 case 300: cout << " Picture-in-a-picture\n";
 case 200: cout << " Stereo sound\n";
 case 100: cout << " Remote control\n";
 break;
 default : cout << "You can only choose the 100, 200, or 300.\n ";
 }

system("pause");
}
Comments