#include <iostream>
using namespace std;
int main()
{
char month;
int minutes, package;
double packageA = 39.99, packageB = 59.99, packageC = 69.99;
double rateA = .45, rateB = .40;
double total = 0.00;
cout << "Enter the name of the month: ";
cin >> month;
//Display packages for user
cout << "Select a subscription package:\n";
cout << "1. Package A\n" << "2. Package B\n" << "3. Package C\n" << "4. Quit\n";
cin >> package;
cout << "How many minutes were used? ";
cin >> minutes;
switch (package)
{
case '1':
{
if (minutes < 450)
total = packageA;
else (minutes > 450);
total = ((minutes - 450)*rateA) + packageA;
break;
}
case '2':
{
if (minutes < 900)
total = packageB;
else(minutes > 900);
total = ((minutes - 900)*rateB) + packageB;
}
default:
{
total = packageC;
}
}
cout << "The total amount due is $" << total;
system("pause");
return 0;
}
It allows the user to type the month, but it doesn't prompt the user for which package to choose. Please advise?
(Sorry I couldn't figure out how to post the code with the line numbers included)
variable month is of type char and I suspect you are typing in more than one character into it; char is inappropriate in this case anyways as April/August, March/May become indistinguishable. Also the month variable doesn't seem to be used anywhere else in the program. If you do have to use month best to use std::string for named months or you could set up an enum with Jan = 1, etc ...