View Single Post
  #3 (permalink)  
Old March 22nd, 2005, 11:53 PM
Alan-LB Alan-LB is offline
Authorized User
 
Join Date: Mar 2005
Posts: 58
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Alan-LB Send a message via Yahoo to Alan-LB
Default

try this (part of program only) -
-----------------------------------------------------------------
int month;
int day;

std::cout << "Enter the Month" << std::endl;
std::cin >> month;

if ((month < 1) || (month > 12))
  std::cout << "Invalid Month entered" << std::endl;
else
  std::cout << "Month acceptable" << std::endl;

std::cout << "Enter the Day" << std::endl;
std::cin >> day;

if ((day < 1) || (day > 31))
  std::cout << "Invalid Day entered" << std::endl;
else
  std::cout << "Day acceptable" << std::endl;

switch (month)
{
  case 1:
  case 2:
  case 3:
    std::cout << "Winter" << std::endl;
    break;
  case 4:
  case 5:
  case 6:
    std::cout << "Spring" << std::endl;
    break;
  case 7:
  case 8:
  case 9:
    std::cout << "Summer" << std::endl;
    break;
  default:
    std::cout << "Winter" << std::endl;
    break;
------------------------------------------------------------
Go to your text books and look up IF and SWITCH in the index. Then read the
text and follow the examples. Then try to write your own code. This will help
you learn C++. Otherwise other people are doing all the work for you and you will not learn.

Alan




Reply With Quote