I am new to c++ programming, and I wrote this program. It runs perfectly but the problem is I want the program to stop If I entered letters other than A,B or C
The code as follows:
// Selection Statement to evaluate the package type that was entered
if ( packageType != 'A')
{
if ( packageType != 'B')
{
if ( packageType != 'C')
{
cout << endl << "Invalid Package Type" ;
}
else
{
// Prompting the user to enter how many hours did the customer use the internet
cout << endl << "Enter the hours that " << customer_name << " use : " ;
cin >> used_hours ;
total_amount = PACKAGE_CCOST ;
package_pay = PACKAGE_CCOST ;
}
}
else
{
// Prompting the user to enter how many hours did the customer use the internet
cout << endl << "Enter the hours that " << customer_name << " use : " ;
cin >> used_hours ;
if (used_hours <= 20)
{
total_amount = PACKAGE_BCOST ;
package_pay = PACKAGE_BCOST ;
}
else
{
// Assignment Statements
add_hours = used_hours - 20; // Calculate how many extra hours did the customer use if his package is B
add_cost = add_hours * ADD_BHOURS_COST ; // Calculate how much does the extra hours cost
total_amount = PACKAGE_BCOST + add_cost ; /* Calculate the total amount that the customer should
pay in the end of the month */
package_pay = PACKAGE_BCOST ;
}
}
}
else
{
// Prompting the user to enter how many hours did the customer use the internet
cout << endl << "Enter the hours that " << customer_name << " use : " ;
cin >> used_hours ;
if (used_hours <= 10)
{
total_amount = PACKAGE_ACOST ;
package_pay = PACKAGE_ACOST ;
}
else
{
add_hours = used_hours - 10 ; // Calculate how many extra hours did the customer use if his package is A
add_cost = add_hours * ADD_AHOURS_COST ; // Calculate how much does the extra hours cost
total_amount = PACKAGE_ACOST + add_cost ; /* Calculate the total amount that the customer should
pay in the end of the month */
package_pay = PACKAGE_ACOST ;
}
}
// The customer information
cout << setw(15) << "Dear Mr/Mrs " << customer_name << endl << endl ;
cout << setw(54) << "Your monthly internet bill is due on May 15, 2014\n\n";
cout << setw(33) << "The bill summary is included\n\n";