I am having issues with a C++ homework problem given to me this afternoon. MY program is telling me i havent properly declared 'a,b,c,A,B,C.' The problem description is :
An Internet service provider has three different subscription
packages for its customers:
Package A: For $15 per month with 50 hours of access provided.
Additional hours are $2.00 per hour over 50 hours.
Assume usage is recorded in one-hour increments,
Package B: For $20 per month with 100 hours of access provided.
Additional hours are $1.50 per hour over 100 hours.
Package C: For $25 per month with 150 hours access is provided.
Additional hours are $1.00 per hour over 150 hours
Assume a 30-day billing cycle.
He wanted to include a "bool flag" with a 'while' loop to stop the user from putting in a lower case letter for the one of the options. Below is my code, i am new so I am sure there is issues. Any help would be appreciated, thank you in advance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
//Internet Service Providers Program3
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
//Variables
char pkg;
int hrs(0);
double total, charges(0);
//Bool Flag
bool flag = true;
while(flag)
{
cout<<"Enter the Internet Package you choose: "<<endl;
cin>>pkg;
if (pkg == a || b || c )
{
flag = false;
cout<<"Invalid Package Option\n\n";
}
else if (pkg == A || B || C)
{
flag = true;
cout<<"Enter the number of hours you need for access: "<<endl;
cin>>hrs;
}
//Plan A
else if (pkg == A && hrs>=50)
{
charges = 15.00 * 50;
total = charges + (hrs-50)*2.00;
cout<<"Your total for Plan A is: $ "<<total
<<endl<<endl;
}
//Plan B
else if (pkg == B && hrs>=100)
{
charges=20.00*100;
total = charges + (hrs-100)*1.50;
cout<<"Your total for Plan B is: $ "<<total
<<endl<<endl;
}
//Plan C
else if (pkg == C && hrs>=150)
{
charges=25.00*150;
total = charges + (hrs-150*1.00);
cout<<"Your total for Plan C is: $ "<<total
<<endl<<endl;
}
else;
}
return 0;
}
|