I have this project but i can't display the months by name, they only come by number. i am stuck can anybody help me?
Thanks

#include <iostream>
#include <iomanip>
using namespace std;

int main ()
{
	string month_name;

	// Constants for package monthly rates
	const double PackageA_RATE = 9.95;
	const double PackageB_RATE = 14.95;
	const double PackageC_RATE = 19.95;

	char Nonprofit;         // Nonprofit Organization Status? ( Y or N )
	char choice;            // Menu choice
	int hours;              // Number of hours
	double charges;         // Monthly charges


	//declaration of local variables
	int		month,					// number for the month
			days,					// number of days in the month
			m_number =0,			// month number
			year;					// year input
	bool    validInput = true,		// flag signaling valid inputt
			leapyear   = false;		// flag signaling leap year

	 obtain and validate inputs from user
	cout << "Enter month name.\n\n"

		 << " January       July\n"
		 << " Feburary      August\n"
		 << " March         September\n"
		 << " April         October\n"
		 << " May           November\n"
		 << " June          December\n\n";

	// check for valid month
	if 	(month_name [0] == 'J' && month_name [1] == 'a')
		m_number = 1;
	
		else if (month_name [0] == 'F' && month_name [1] == 'e' )
		m_number = 2;
	
		else if (month_name [0] == 'M' && month_name [1] == 'a' && month_name [2] == 'r')
		m_number = 3;
	
		else if (month_name [0] == 'A' && month_name [1] == 'p' )
		m_number = 4;

		else if (month_name [0] == 'M' && month_name [1] == 'a' && month_name [2] == 'y')
		m_number = 5;

		else if (month_name [0] == 'J' && month_name [1] == 'u' && month_name [2] == 'n')
		m_number = 6;

		else if (month_name [0] == 'J' && month_name [1] == 'u' && month_name [2] == 'l' )
		m_number = 7;

		else if (month_name [0] == 'A' && month_name [1] == 'u' )
		m_number = 8;

		else if (month_name [0] == 'S' && month_name [1] == 'e' )
		m_number = 9;

		else if (month_name [0] == 'O' && month_name [1] == 'c' )
		m_number = 10;

		else if (month_name [0] == 'N' && month_name [1] == 'o' )
		m_number = 11;

		else if (month_name [0] == 'D' && month_name [1] == 'e' )
		m_number = 12;
	
	cin >> month;
	if (m_number < 1 || m_number > 12)   // check for valid month
	{
			cout << "\nMonth must be between 1-12. \n";
			validInput = false;
	}
	else             // valid month so calculate number of days
	{
		cout << "Enter year  (1582-9999): ";
		cin >> year;
		if (year < 1582 || year > 9999)  // check for valid year--invalid
		{
			cout << "\nYear must be between (1582-9999). \n";
			validInput = false;
		}
		else
		{
			switch(m_number)
			{
			case 'Ja':                  //31 days months
			case 'Mar' :
			case 'May':
			case 'Jul':
			case 'Au':
			case 'Oc':
			case 'De':
				days = 31;
				break;
			case 'Ap':               //30 days months
			case 'Jun':
			case 'Se':
			case 'No':
				days = 30;
				break;
			case 'Fe':              //Feburary as a special case
				if (((year % 4 ==0) && (year % 100 != 0)) || (year % 400 == 0))
				{
					leapyear = true;
					days = 29;
				}
				else
					days = 28;
			}//end switch
		}
		if (validInput)         //month and year were OK
		{
			cout << "\nThe Month  " << month
				<< " in year "  << year
				<< " has " << days << endl;
		}
	}
	*/
	// Display the menu and get the user's choice
	cout << " Internet Subscription Package Menu \n\n ";

	cout <<	" Package A: 10 hours of free access for $ 9.95 per month. Additional hours are $ 2.00 per hour   \n \n";
	cout << " Package B: 20 hours of free access for $ 14.95 per month. Additional hours are $ 1.00 per hour  \n \n";
	cout << " Package C: Unlimited access for $19.95 per month  \n \n";

	cout << " Enter Package type (A, B, C )or Q to exit : \n \n";
	cin >> choice;
	
	switch (choice)
	{
	case 'A' : cout << "You entered A. \n";
			  break;
	case 'B' : cout << "You entered B. \n";
			  break;
	case 'c' : cout << "You entered C. \n";
			  break;
	default: cout << "nInvalid Selection (Please Enter A, B, or C!) \n";
	}
	cout << " Do you have a Nonprofit Organization Status \n \n";
	cout << " Enter Y for Yes or N for No. \n \n";
	cin >> Nonprofit;

	// Set the numeric output formatting
		cout << fixed << showpoint << setprecision (2); 

	// Use the menu selection to execute the correct set of actions
		if (choice == 'A')
		{	cout << "\n Number of hours used? " << endl;
			cin >> hours;
			if (hours <= 10) 
			{
				charges = PackageA_RATE;
			}
			else
			{
				charges = PackageA_RATE + (hours - 10) * 2;
			}
		 }
		else if (choice == 'B')
		{		cout << "\n Number of hours used? ";
				cin >> hours;
				if (hours <= 20)
				{
					charges = PackageB_RATE;
				}
				else
				{
					charges = PackageB_RATE + (hours - 20);
				}
		}
		else if (choice == 'C')
		{	 
			charges = PackageC_RATE;
		}	
		if (Nonprofit == 'Y')   
		{
			cout << "\nYou qualify for the additional 10% discount.\n";
			charges = .90 * (charges);
			cout << " Your charges are: " << charges << endl;
		}
		else if
		{

					
	return 0;
		
}

the item inside the switch() parenthesis must resolve to an int. That means each case must resolve to an int. 'Ja' is not an int. In fact it isn't anything. 'J' is a char and char are interpreted as ints by the computer so that works. "Ja" is a string, but not a char and not an int. 'Ja' however isn't anything. Use this syntax instead:

case 1:
case 3:
case 5:
days = 31;
break;

etc

First I would create an array of valid month names, such as

string months[] = {"January","February","March" ... };

Then after the user enter the month name just create a loop and compare them

int i;
for(i = 0; i < 12; i++)
{
   if( month_name == months[i] )
   {
        // found it
   }
}

After the above is complete, the value of the i counter is the month number that you can use in that switch statement

switch(i)
{
    case 0: // January
    case 2: // march
         days = 31;
   // etc.
}

On line 37 add cin >> month_name;.

Line 76 should refer to month, not m_number and isn't necessary since you already have m_number.

To get the name of the month to appear on line 121 you can use another switch() statement

switch(m_number)
{
  case 1:
     cout << "January";
     break;
  case 2:
     cout << "Febuary";
     break;
  etc
}
This article has been dead for over six months. Start a new discussion instead.