please help me fix and finish off my assignment

Question: An Internet service provider has three different subscription packages for its customers.
Package A: For $9.95 per month 5 hours of access are provided. Additional usage costs $0.08 per minute.
Package B: For $14.95 per month 10 hours of access are provided. Additional usage costs $0.06 per minute.
Package C: For $19.95 per month unlimited access are provided.

Write a program that calculates and lists a customer’s monthly bill. A user should input customer name, which package the customer has purchased, and how many hours were used. It should then create a bill that includes the input information and the total amount due.

Input Validation: Be sure the user only selects package A, B, or C.

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
#include <iostream>
using namespace std;

int main ()
{
  //Declaration.
  
int choice;
int hours;
int choixOperation;
int name;
double total;

double A = 9.95;
double B = 14.95;
double C = 19.95;
double D = 0.08;
double E = 0.06;

 //Display.

cout << " \t\tThe Internet Service Provider Subscription\n";
cout << "1. A.$9.95 per month. 5 hours access. Additional Minutes are $0.08\n";
cout << "2. B.$14.95 per month. 10 hours access. Additional minutes are $0.06\n";
cout << "3. C.$19.95 per month. Unlimited access.\n";
cout << "Enter your choice: ";
cin >> choice;

 //Calculation.
 
if (choice >=1 && choice <=3)
{
  //Input information 
  
cout << "Can I have your full name please: ";
cin >> name;
 //Neeed!!
 
cout << "How many hours would you access: ";
cin >> hours;

 //Decision.

switch (choixOperation)
{
case 1:
{
total = A + (hours - 5)*(.08);
break;
}
case 2: 
{
total = B + (hours - 10)*(.06);
break;
}

case 3: 
{
total = C;
break;
}


I have not been able to continue the rest where it should create the bill that includes the input information and the total amount due. Please help, with any error fixes and help on the last part to display the bill.
Read lines 11, 39, and 48

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
#include <iostream>
using namespace std;

int main ()
{
      //Declaration.

    int choice;
    int hours;
    int choixOperation;
    int name; // Does this make sense? Think logically... You're storing a name into an int data type...
    double total;

    double A = 9.95;
    double B = 14.95;
    double C = 19.95;
    double D = 0.08;
    double E = 0.06;

     //Display.

    cout << " \t\tThe Internet Service Provider Subscription\n";
    cout << "1. A.$9.95 per month. 5 hours access. Additional Minutes are $0.08\n";
    cout << "2. B.$14.95 per month. 10 hours access. Additional minutes are $0.06\n";
    cout << "3. C.$19.95 per month. Unlimited access.\n";
    cout << "Enter your choice: ";
    cin >> choice;

     //Calculation.

    if (choice >=1 && choice <=3)
    {
          //Input information

        cout << "Can I have your full name please: ";
        cin >> name;
         //Neeed!!

        cout << "How many hours would you access: "; // Do you really want to print this line?
        cin >> hours;                                // If users choose option
                                                     // three, do you really
                                                     // want to ask them how
                                                     // much hours they want
                                                     // access to?

         //Decision.

        switch (choixOperation) // Look at your code. You're performing conditional check on this variable
        {                       // even though you've not set it to anything yet. Perhaps you want to perform
            case 1:             // check conditional check on 'choice' instead?
            {
                total = A + (hours - 5)*(.08);
                break;
            }
            case 2:
            {
                total = B + (hours - 10)*(.06);
                break;
            }

            case 3:
            {
                total = C;
                break;
            }
        }
    }
    // It should not be hard to print the name and the total after you've fixed
    // some of your errors.
}
so can i remove lines 17, 18:
1
2
    double D = 0.08;
    double E = 0.06;


for line 39 i would have to connect it with plans 1 and 2?
with total plan1= (hours + cost - hours) * 0.8 or 0.6 like the line i have in 52-63?
 
   cout << "How many hours would you access: ";


but how do i declare cost without it being a function?
can i use this code??

1
2
3
4
5
  double aCost = cost(minutes, 'A');
  double bCost = cost(minutes, 'B');
  double cCost = cost(minutes, 'C');
  double yourCost = cost(minutes, plan);
so can i remove lines 17, 18:

If you're not going to use them in your program, remove them.

for line 39 i would have to connect it with plans 1 and 2?

Yes.

but how do i declare cost without it being a function?
can i use this code??

If you don't want to declare cost without using a function, just perform the basic computation for the cost like what you did for your original code. You may use a function as well to do the computations.
Thank you so much life savor!
To give you an idea.

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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <iostream>
#include <string>


int displayMenu();
void displayDescriptionPackages();
void packageA(std::string&, char[], int, double);
void packageB(std::string&, char[], int, double);
void packageC(std::string&, char[], int, double);
void displayBill(std::string, char[], int, int&, double);

enum menuChoices { PACKAGE_A = 1, PACKAGE_B, PACKAGE_C, EXIT };

int main()
{
	std::string customerName{};
	char package[]{ 'A', 'B', 'C' };
	int hours{};
	double total{};

	bool keepLooping{ true };
	while (keepLooping)
	{
		int choice{ displayMenu() };

		std::cin.ignore();
		std::cout << "Input the name of the customer: ";
		std::getline(std::cin, customerName);

		switch (choice)
		{

		case PACKAGE_A:
			packageA(customerName, package, choice, total) ;
			keepLooping = true;
			break;

		case PACKAGE_B:
			packageB(customerName, package, choice, total);
			keepLooping = true;
			break;

		case PACKAGE_C:
			packageC(customerName, package, choice, total);
			keepLooping = true;
			break;

		case EXIT:
			std::cout << "Program ending.\n";
			keepLooping = false;
			break;

		default:
			std::cout << "Your choice " << choice << " is incorrect.\n";
			std::cout << "Your choices are between " << PACKAGE_A <<
				" and " << EXIT << std::endl;
		}
	}

    return 0;
}

int displayMenu()
{
	int choice{};
	std::cout << "\n\t\t\t==========Internet Service Provider==========\n";
	std::cout << "\t\t\t----------------------------\n";
	std::cout << "\t\t\t1. Package A.\n";
	std::cout << "\t\t\t2. Package B.\n";
	std::cout << "\t\t\t3. Package C.\n";
	std::cout << "\t\t\t4. Exit the Program\n";
	std::cout << "\t\t\t------------------------------------------------\n";
	displayDescriptionPackages();
	std::cout << "\nSelect the package the customer wants: ";
	std::cin >> choice;

	return choice;
}

void displayDescriptionPackages()
{
	std::cout << "\n\t\t\t==========Description==========\n";
	std::cout << "\t\t\t----------------------------\n";
	std::cout << "\t\t\t   Package A.\n";
	std::cout << "\t\t\t    - $9.95 per month.\n";
	std::cout << "\t\t\t    - 5 hours access.\n";
	std::cout << "\t\t\t    - Additional minutes are $0.08\n";
	std::cout << "\t\t\t   Package B.\n";
	std::cout << "\t\t\t    - $14.95 per month.\n";
	std::cout << "\t\t\t    - 10 hours access.\n";
	std::cout << "\t\t\t    - Additional minutes are $0.06\n";
	std::cout << "\t\t\t   Package C.\n";
	std::cout << "\t\t\t    - $19.95 per month.\n";
	std::cout << "\t\t\t    - Unlimited Access.\n";
}

void packageA(std::string &name, char package[], int choice, double total)
{
	const double price{ 9.95 };
	const int hoursAccess{ 5 };
	const double costPerMin{ 0.08 };
	const int totalMinsIntoHrs{ 60 };
	int hours{};
	std::cout << "How many hours " << name << " used: ";
	std::cin >> hours;

	if (hours > hoursAccess)
	{
		total = price + ((hours - hoursAccess) * (costPerMin * totalMinsIntoHrs));
	}
	else
		total = price;

	displayBill(name, package, choice, hours, total);
}

void packageB(std::string &name, char package[], int choice, double total)
{
	const double price{ 14.95 };
	const int hoursAccess{ 10 };
	const double costPerMin{ 0.06 };
	const int totalMinsIntoHrs{ 60 };
	int hours{};
	std::cout << "How many hours " << name << " used: ";
	std::cin >> hours;

	if (hours > hoursAccess)
	{
		total = price + ((hours - hoursAccess) * (costPerMin * totalMinsIntoHrs));
	}
	else
		total = price;

	displayBill(name, package, choice, hours, total);
}

void packageC(std::string &name, char package[], int choice, double total)
{
	const double price{ 19.95 };
	int hours{};

	total = price;

	displayBill(name, package, choice, hours, total);
}

void displayBill(std::string name, char package[], int choice, int &hours, double total)
{
	if (choice == PACKAGE_C)
	{
		std::cout << "\n\t\t\t==================Payment Due================\n";
		std::cout << "\t\t\t-----------------------------------------------\n";
		std::cout << "\t\t\t   Customer Name: " << name << " .\n";
		std::cout << "\t\t\t   Package " << package[choice - 1] << " .\n";
		std::cout << "\t\t\t   Hours Used: UNLIMITED .\n";
		std::cout << "\t\t\t   Total Amount Due: " << total << " .\n";
		std::cout << "\t\t\t------------------------------------------------\n";
	}
	else
	{
		std::cout << "\n\t\t\t==================Payment Due================\n";
		std::cout << "\t\t\t-----------------------------------------------\n";
		std::cout << "\t\t\t   Customer Name: " << name << " .\n";
		std::cout << "\t\t\t   Package " << package[choice - 1] << " .\n";
		std::cout << "\t\t\t   Hours Used: " << hours << " .\n";
		std::cout << "\t\t\t   Total Amount Due: " << total << " .\n";
		std::cout << "\t\t\t------------------------------------------------\n";
	}

}
Topic archived. No new replies allowed.