I need help from anyone on my program

I would like to add this cout << "PRESS E TO EXIT THE PROGRAM " << endl; right after
cout << "C\t\t$19.95\t\tUnlimited\t\tUnlimited" << endl;

That way the user will have the option to exit the program. Could you please tell me what I need to add in order to make it work? I basically just want the user to have the option to exit the program when he chooses to. Any solutions are welcome.

Also How do I do keep this program running until the users presses E to exit. Once the user chooses his package and get his balance I want him to have the option to go back and choose another package without having to restart the program.

Thank you so much.

I wrote all this so far:

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
char package;
const double planA = 9.95;
const double planB = 14.95;
const double planC = 19.95;

double hours;
double currentBill;
double currentBillb;


cout << "Select a package: \n" << endl;
cout << "Package\t\tCost\t\tHours Provided\t\tExtra Hours" << endl;
cout << "A\t\t$9.95\t\t10\t\t\t$2.00 per hour" << endl;
cout << "B\t\t$14.95\t\t20\t\t\t$1.00 per hour" << endl;
cout << "C\t\t$19.95\t\tUnlimited\t\tUnlimited" << endl;

cout << "\nEnter the package purchased: ";
cin >> package;
while(package!= 'A' && package!='a' && package!='B' && package!='b'&&
package!='C' && package!='c')
{cout <<"\nError! You must select package A, B, or C. ";
cout <<"Enter the package purchased: ";
cin >> package;}

cout <<"\nEnter the number of hours used: ";
cin >>hours;
cin.get();
while(hours < 0 || hours > 744)
{cout <<"\nError! Hours cannot be negative or exceed 744. \n\nYou must enter appropriate hours.";
cout <<"\n\nEnter the number of hours used. ";
cin >> hours;}

if(package == 'A' || package == 'a')
{if (hours <= 10)
cout<<"\nYour monthly fee is: $9.95"<<endl;
else cout<<"\nYour monthly fee is: $"<<9.95+(hours-10)*2<<endl;}


currentBill = (9.95+(hours-10)*2);

if(package == 'A' || package == 'a')

if ((hours >= 13) && (hours <=20))
{cout<<"\nAccording to your current bill: $"<<currentBill<<" if you were to switch to Plan B, You\n\ncould save: $"<<currentBill-planB<<endl;}

else if (hours > 20)
{cout<<"\nAccording to your current bill: $"<<currentBill<<" if you were to switch to Plan C, You\n\ncould save: $"<<currentBill-planC<<endl;}






if(package == 'B' || package == 'b')
{if (hours <= 20)
cout<<"\nYour monthly fee is: $14.95"<<endl;
else cout<<"\nYour monthly fee is: $"<<14.95 + (hours - 20)<<endl;}

currentBillb = (14.95 + (hours - 20));

if(package == 'B' || package == 'b')

if (hours > 25)
{cout<<"\nAccording to your current bill: $"<<currentBillb<<" if you were to switch to Plan C, You\n\ncould save: $"<<(currentBillb-planC)<<endl;}


else if (hours <= 10)
{cout<<"\nAccording to the total of hours you used this month : "<<hours<<" hours. If you were to\n\nswitch to Plan A, You\n\ncould save: $"<<abs(currentBillb-planA)<<endl;}



if(package == 'C' || package == 'c')
cout<<"\nYour monthly fee is: $19.95"<<endl;

if(package == 'C' || package == 'c')

if ((hours <= 20 && hours>10))
{cout<<"\nAccording to the total of hours you used this month : "<<hours<<" hours. If you were to\n\nswitch to Plan B, You\n\ncould save: $"<<abs(planC-planB)<<endl;}


else if (hours <= 10)
{cout<<"\nAccording to the total of hours you used this month : "<<hours<<" hours. If you were to\n\nswitch to Plan A, You\n\ncould save: $"<<abs(planC-planA)<<endl;}








cin.get();
return 0;
}

@KORNFREDY

How do I do keep this program running until the users presses E to exit.


Here is one way to do that. I had tho add in a couple do/while loops and such. Of course, the program would look a lot better, and be easier to follow, if you used the switch command.
I changed the dollar amounts you had hard coded in the program. This way, if the amounts changed in the plans, you only have to change the three listed in your constants, otherwise, you would have to search each line and change the dollar values listed or you will receive incorrect results.
I also made the input to always be uppercase, so you don't have to check both upper and lowers.
One last thing, use the code format button on the right side. ( They look like <> )
After pasting in your code, highlight it, and click on the format button. As you can see with the code below, it's easier to read, and comment on, since you see line numbers as well.

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Packages.cpp : main project file.

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	char package;
	const double planA = 9.95;
	const double planB = 14.95;
	const double planC = 19.95;

	double hours;
	double currentBill;
	double currentBillb;

	do
	{
		package = ' ';
		cout << "Select a package: \n" << endl;
		cout << "Package\t\tCost\t\tHours Provided\t\tExtra Hours" << endl;
		cout << "A\t\t$" << planA <<"\t\t10\t\t\t$2.00 per hour" << endl;
		cout << "B\t\t$" << planB <<"\t\t20\t\t\t$1.00 per hour" << endl;
		cout << "C\t\t$" << planC <<"\t\tUnlimited\t\tUnlimited" << endl << endl;
		cout << "E\t\t EXIT THE PROGRAM" << endl;
		while((package<  'A' || package > 'C') && package != 'E')
		{
			cout << "\nEnter the package purchased: ";
			cin >> package;
			package = toupper(package);
			if((package<  'A' || package > 'C') && package != 'E' )
				cout <<"\nError! You must select package A, B, or C. ";
		}
		if(package != 'E')
		{
			cout <<"\nEnter the number of hours used: ";
			cin >>hours;
			//cin.get();
			while(hours < 0 || hours > 744)
			{
				cout <<"\nError! Hours cannot be negative or exceed 744. \n\nYou must enter appropriate hours.";
				cout <<"\n\nEnter the number of hours used. ";
				cin >> hours;
			}

			if(package == 'A')
			{
				if (hours <= 10)
					cout<<"\nYour monthly fee is: $" << planA <<endl;
				else
					cout<<"\nYour monthly fee is: $"<<planA+(hours-10)*2<<endl;}


			currentBill = (planA+(hours-10)*2);

			if(package == 'A')
			{
				if (hours >= 13 && hours <=20)
				{
					cout<<"\nAccording to your current bill: $"<<currentBill<<" if you were to switch to Plan B,\nyou would save: $"<<currentBill-planB<<endl;
				}
				else if (hours > 20)
				{
					cout<<"\nAccording to your current bill: $"<<currentBill<<" if you were to switch to Plan C,\nyou would save: $"<<currentBill-planC<<endl;
				}
			}
			if(package == 'B')
			{
				if (hours <= 20)
					cout<<"\nYour monthly fee is: $" << planB <<endl;
				else
					cout<<"\nYour monthly fee is: $"<< planB + (hours - 20) <<endl;
			}

			currentBillb = (planB + (hours - 20));

			if(package == 'B')
			{
				if (hours > 25)
				{
					cout<<"\nAccording to your current bill: $"<<currentBillb<<" if you were to switch to Plan C, You\n\ncould save: $"<<(currentBillb-planC)<<endl;
				}
				else if (hours <= 10)
				{
					cout<<"\nAccording to the total of hours you used this month : "<<hours<<" hours. If you were to\n\nswitch to Plan A, You\n\ncould save: $"<<abs(currentBillb-planA)<<endl;
				}
			}

			if(package == 'C')
			{
				cout<<"\nYour monthly fee is: $" << planC <<endl;

				if ((hours <= 20 && hours>10))
					cout<<"\nAccording to the total of hours you used this month : "<<hours<<" hours. If you were to\n\nswitch to Plan B, You\n\ncould save: $"<<abs(planC-planB)<<endl;
				else if (hours <= 10)
					cout<<"\nAccording to the total of hours you used this month : "<<hours<<" hours. If you were to\n\nswitch to Plan A, You\n\ncould save: $"<<abs(planC-planA)<<endl;
			}
		}
	}while(package !='E' );
	cout << endl << endl << "Thanks for shipping with us.." << endl;
	cin.get();
	return 0;
}
@whitenite1
Thank you for your help. I was wondering if you could please delete your post since I dont want my teacher to know I got helped from you guys.

Thank you very much :)
Thank you, whitenite for quoting the OP's post.

KORNFREDY: It's a jerk move to delete your post after you receive a response. Those of us that respond to questions here do so because our responses can help multiple people, not just the original poster. If you delete your post it destroys that possibility and makes us feel like we've wasted our time.


No teacher is going to dock you for getting help with an assignment as long as you do the assignment yourself. The only thing they don't like is when people get full answers off the net.

And if your teacher really doesn't want you to get online help... then you shouldn't be getting online help. (or... I would say... get a better teacher)
@Disch

I see that someone, ( probably KORNFREDY ), reported me. Will this hurt my reputation? Also, is there a way for it to be cleared, either now, or maybe, in the near future?
Don't worry about it. There is no reputation system here; the admin just reviews reported posts and will see that there is nothing wrong with yours.
Topic archived. No new replies allowed.