Billing program slight problem

there is a problem there in line 64
because the it wont add it will just appear total already it must have added


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

int main ()
{
int choice;
int channel;
int con;

double total;

double A = 25;
double B = 90;
double C = 90;
double D = 7.50;
double E = 5.00;

//Display
cout << " \t\t\tCable Company Billing\n\n";
cout << "1. For Residence Customers\n";
cout << "2. For Business Customers\n";
cout << "Enter your choice 1 or 2: ";
cin >> choice;

if (choice >=1 && choice <=2)
{
cout << "How many Premium channels subscribed in?: ";
cin >> channel;



switch (choice)
{
case 1:
{
total = A + (channel)*D;
break;
}
case 2:
{
	if(channel > 0)
	{
		channel = 50;
	}
total = B + (channel);
break;
}



default:
cout<<"You enter a wrong value!"<<endl;
cout << "The valid choices are 1 through 3. \n Run the program again.";

}
{
	if(choice = 2) //Here the total will just be total it wont add the (con-10)*D; 
{
	cout << "How many connections All in All?: ";
cin >> con;
switch (choice)
	case 3:
{
total = B + (con - 10)*D;    //here it will only tell the total it wont add up the(con-10)*D;
break;
}
}
}


cout << "The total charges is equal to: $"<<total<<endl;
}

else if (choice !=2)

{
cout << "The valid choices are 1 through 2. \n Run the program again.";
}
return 0;
}
closed account (zwA4jE8b)
Nevermind.... bad post.
Last edited on
CreativeMFS,
Notice here your default is not in the switch / case!!!
No, that '}' belongs to case 2: hence
Extra brace here!! This brace closes MAIN
is wrong as well
closed account (zwA4jE8b)
oh yeah, i didn't notice that
Hm, yes the curly braces are misplaced.

Back to the problem. It starts on line 57. This if(choice = 2) must be if(choice == 2) // Note == .

But why don't you do it within the switch after case 2:?

The switch on line 61 does not make sense remove it.
Topic archived. No new replies allowed.