I have a problem:
Here is my program:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <conio>
using namespace std;
int main()
{
char choice;
string name;
int hours;
double charges, total;
cout << "\t\tInternet Service Provider\n";
cout << "\t\tSubscription Packages\n\n";
cout << "A: For $9.95 per month, can get 10 hours of\n";
cout << " access. Additional hours are $2.00 per hour. \n\n" ;
cout << "B: For $14.95 per month, you can get 20 hours\n";
cout << " of access. Additonal hours are $1.00 per hour. \n\n";
cout << "C: For $19.95 per month unlimited access is provided.\n\n";
cout << "Please enter your name. ";
getline (cin, name);
cout << "Which subscription package would you like? ";
cin.get(choice);
cout << fixed <<showpoint <<setprecision(2);
cout << "How many hours did you use for this month? ";
cin >> hours;
if (choice == 'A' || 'a')
{
if (hours >=10)
{
charges = 9.95;
total = charges + ((hours - 10) * 2.00);
cout << name << " your total payment for this month is $" << total <<endl;
}
else cout << name << " your total payment for this month is $" << charges << endl;
}
else if (choice == 'B' || 'b')
{
charges = 14.95;
if (hours >=20)
{
cout << name << " your total payment for this month is $" << charges << endl;
}
else
cout <<name << "your total payment for this month is $" << charges << endl;
total = charges + ( (hours - 20) * 1.00) ;
}
else if (choice == 'C' || 'c')
{
charges = 19.95;
cout <<name << " your total payment for this month is $" << charges << endl;
}
else if (choice !='C' || hours != 744)
{ cout << "You must choose packages A, B, or C. Also, your hours\n";
cout << "must not exceed 744.\n";
}
getch();
return 0;
}
Here is my problem:
When I run the program and choose C for my choice, it should output the name of the subscriber, and your total payment for this month is $19.95 (since it's unlimited). But, this is what happens:
Internet Service Provider
Subscription Packages
A: For $9.95 per month, can get 10 hours of
access. Additional hours are $2.00 per hour.
B: For $14.95 per month, you can get 20 hours
of access. Additonal hours are $1.00 per hour.
C: For $19.95 per month unlimited access is provided.
Please enter your name. Nadia McIntosh
Which subscription package would you like? C
How many hours did you use for this month? 35
Nadia McIntosh your total payment for this month is $59.95
Also, everything in the first subscription choice (which is A) calculates fine and everything. But, watch what happens when I choose B:
Internet Service Provider
Subscription Packages
A: For $9.95 per month, can get 10 hours of
access. Additional hours are $2.00 per hour.
B: For $14.95 per month, you can get 20 hours
of access. Additonal hours are $1.00 per hour.
C: For $19.95 per month unlimited access is provided.
Please enter your name. Nadia McIntosh
Which subscription package would you like? B
How many hours did you use for this month? 25
Nadia McIntosh your total payment for this month is $39.95
See what happens..My calculations are all wrong.
What's wrong??:X