I am working on an program in Borland C++ Builder 6 in which I have to create a program that asks the user for their name, what package they choose, and how many hours did they use. (Keep in mind that this program is not completed.)
Well, I have the program, and here it is.
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <iomanip> //Needed for the showpoint and setprecison command
- #include <fstream> //Needed to use files
- #include <string>
- #include <conio> //Needed to show black output screen
- using namespace std;
- int main()
- {
- char choice;
- int hours;
- string name;
- double charges;
- // Displays the menu choices on the screen.
- 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?\n";
- cin.get(choice);
- cout << fixed <<showpoint <<setprecision(2);
- if (choice == 'A' || 'a')
- {
- charges = 9.95 + (
- cout << "Your charges are $ " << charges << endl;
- }
- else if (choice == 'B'||'b')
- {
- charges =
- cout << "Your charges are $ " << charges << endl;
- }
- else if (choice == 'C' || 'c')
- {
- charges =
- cout << "Your charges are $ " << charges << endl;
- }
- else if (choice > 'C' || >744)
- { cout << "You must choose packages A, B, or C. Also, your hours\n";
- cout << "must not exceed 744.\n";
- }
- getch();
- return 0;
- }
I am trying to find out what calculations to use on the charges line.
The choices are:
A- $9.95 a month 10 hours are provided. Additional hours are $2.00 per hour.
B. $14.95 a month 20 hours are provided. Additonal hours are $1.00 per hour.
C. $19.95 per month. Unlimted access is provided.
For example, if a user chooses package A, and they use 15 hours that month, then that user would pay the $9.95 charge (for the 10 hours) plus an additional $10.00 ($2.00 * $5.00), which would be $19.95. I know how to calculate it, I just need help figuring out how to write it in C++.
Any input is appreciated.