Re: If statements inside switch statements?

  • From: "Bill Gallik" <BillGallik@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 27 Jul 2010 01:27:24 -0500

Jess,

Well, looked at your code snippet and have modified it very slightly. I can't say if your cout statements are syntactically correct, but you either had included left braces where not needed or didn't include the matching right braces as required.

Here's the modified code:
----------------
if (nights <= 0)
{
cout << "Error, must be greater than 0. ";
}    // You forgot this right brace
else if (nights == 1)
{
cout << "You have selected to stay for a single night. ";
}    // You also forgot this right brace
else if (nights > 1) // You really don't need the "if" construct here -- what else could it possibly be? The "else" alone would have sufficed
{
cout << "You have selected to stay for "; cout << nights; cout << "nights. ";
} //end if
// Notice that I replaced the right bracket with a right brace directly above
----------------

By the way, I too apologize for taking so long to respond. I invited a woman friend over for a very late dinner -- grilled New York on the charcoal grill, made a knock out salad and some hash browns. Yum, Yum!!!

She's leaving for Idaho on Wednesday and I wanted to have her for dinner before she left (take that any way you like). Of course, nothing romantic happened; she was very forthright in telling me that she could not get her "head around being with a blind man." Well, let me tell you (all of you), although it sounds horribly cruel on the surface, I do appreciate her honesty. There's another gal that I truly fancy and she will admit her prejudice to herself, always make up some character flaw in me that I don't have - either I'm a pot head, a drunk, a manipulator or whatever she can dream up to justify not "liking" me. I wish that one would be as honest with me (and herself). I'm waiting for her to accuse me of being a Communist spy next! ;-)

Sorry for the diatribe!

----
Holland's Person, Bill
E-Mail: BillGallik@xxxxxxxxxxxxxx
- The early bird may get the worm, but the second mouse gets the cheese!
__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: