[prog] C++

Namik Dala lc-programming at nada.refused.cc
Tue Jan 20 15:39:22 EST 2004


On Tue, Jan 20, 2004 at 07:49:10AM -0500, wolf wrote:
> 	cin    >> Choice;

You're reading in Choice,

> 	cout << endl;
> 	
> 	if (Choice = 1)

And here you set Choice to 1. It doesn't matter what you've
entered before. Maybe you want to remove the if-clause.

> 		switch (Choice)
> 			
> 		{
> 			
> 			case 1:
> 				
> 				cout << "Your choice is 1.";
> 				
> 				break;
> 				
> 			case 2:
> 				
> 				cout << "Your choice is 2.";
> 				
> 				break;
> 				
> 			default:
> 				
> 				cout << "Next flight leaves in 3 hours." << 
> 				endl;
> 				
> 		}

You're setting Choice to 1, therefore only case 1 is matching.
The default statement executes only if Choice is not 1 or 2,
because of the break statements in the cases.

If you want to execute the default in any case, remove the
break statements.

						-Namik-


More information about the Programming mailing list