All pastes #135876 Raw Edit

Someone

public cpp v1 · immutable
#135876 ·published 2006-08-17 07:32 UTC
rendered paste body
/******  Author: Dion Hulse* Program: ISY00245 - Principals of Programming - CA2* Version: 1*    Date: 17/August/06* Purpose: Display the name of a entered month, ^           and optionally, the number of days in the month******/#include <iostream> //Basic Input/Output#include <string> //String handlingusing namespace std;void funcDisplayMonthName(int& intMonth); //Function to Display the month Namevoid funcDisplayMonthDays(int& intMonth); //Function to Display the number of                                           //days in a monthvoid funcGetInputMonth(int& intMonth);    //Function to input the month numberbool funcGetInputMonthDays(void);         //Function to ask to know the number                                           //of days in a monthint main(){   int intMonth; //Store the number of the month in. Passed as reference to most                 //functions.   funcGetInputMonth(intMonth); // Retrieve the input month   funcDisplayMonthName(intMonth); //Display the name of the given month      if(funcGetInputMonthDays() == true) //If user wants to see the number of days   {                                   //in a month      funcDisplayMonthDays(intMonth);  //Displays number of days in month   }   //system("cmd /c pause"); //CygWin pause command.   return 0;} //End main/*** Function to display the name of the month.* Accepts: int intMonth: number of the month* Returns: void.**/void funcDisplayMonthName(int& intMonth){   cout << "The name of the " << intMonth << " Month is ";   switch(intMonth) //Switch the month number, and display the month name   {      case 1:         cout << "January";         break;      case 2:         cout << "February";         break;      case 3:         cout << "March";         break;      case 4:         cout << "April";         break;      case 5:         cout << "May";         break;      case 6:         cout << "June";         break;      case 7:         cout << "July";         break;      case 8:         cout << "August";         break;      case 9:         cout << "September";         break;      case 10:         cout << "October";         break;      case 11:         cout << "November";         break;      case 12:         cout << "December";         break;      default:         cout << "Invalid Month";         break;   } //End switch(intMonth)   cout << "." << endl;   return;}//End funcDisplayMonthName/*** Function to display the number of days in a month* Accepts: int intMonth: number of the month* Returns: void.**/void funcDisplayMonthDays(int& intMonth){   cout << "In the " << intMonth << " Month there is ";   switch(intMonth) //Switch on month name to determine number of days in month.   {      case 1:      case 3:      case 5:      case 7:      case 8:      case 10:      case 12:         cout << "31";         break;      case 4:      case 6:      case 9:      case 11:         cout << "30";         break;      case 2:         cout << "28";         break;      default:         cout << "Invalid Month";         break;   } //End switch(intMonth)   cout << " Days." << endl;   return;}//End funtDisplayMonthDays/*** Function to accept input of month number* Accepts: int intMonth: number of the month* Returns: void.**/void funcGetInputMonth(int& intMonth){   cout << "Please enter the number of the month you wish to view:\t";   cin >> intMonth;   return;}//End funcGetInputMonth/*** Function to accept, and determine, whether or not to display the number of* days in a month.* Accepts: void.* Returns: bool true on y answer, bool false on any other answer.**/bool funcGetInputMonthDays(void){   string stringAnswer; //String to store result into from keyboard.   cout << "Do you wish to view the number of days in the month? [y/N] ";   cin >> stringAnswer;      if("y" == stringAnswer || "Y" == stringAnswer)   {      return true;   }    else    {      return false;     }}//End funcGetInputMonthDays