Hi.
Well, I got my subscription program right (thanks for all of the help, everyone!):)
#include <iostream>
#include <iomanip> //Needed for the showpoint and setprecison command
#include <fstream> //Needed to use files
#include <string> //Needed to use string variable
#include <conio>
using namespace std;
int main()
{
char choice;
string name;
int hours;
double charges, total;
// Displays the menu choices on the screen.
cout << "\t\tInternet Service Provider\n";
cout << "\t\t Subscription 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);
if (choice == 'A' || choice == 'a')
{
cout << "How many hours did you use for this month? ";
cin >> hours;
charges = 9.95;
if (hours >=10)
{
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 $";
cout << charges << endl;
}
else if (choice == 'B' || choice == 'b')
{
cout << "How many hours did you use for this month? ";
cin >> hours;
charges = 14.95;
if (hours >=20)
{
total = charges + ((hours - 20) * 1.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 == 'C' || choice == 'c')
{
charges = 19.95;
cout << name << ", your total payment for this month is $" << charges << endl;
}
else if
(choice !='C' && 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;
}
The only problem that I am having now is writing the information to a file called subscriptionbill.txt. I would like the following in the program:
(1) The header
(2) The subscription that the person chose
(3) Their monthly bill
(4) The statement: "Thanks for doing business with us!"
Can anyone help me out or at least direct me to a good tutorial that could point me in the right direction when it comes to writing files?
Thanks!:cool: