C++ Cable bill calculation

I am doing something wrong within my code. I'm pretty sure I did not declare the letters right, I'm not sure how that is done. I'm sure other things are wrong too, I did my best. Please help me out here!!


#include<iostream>


int main()
{
int resident;
// Here, I declare resident as a variable (of integer type).
const double resProcessingFee = 4.50;
const double resBasicServices = 20.50;
const double resPremiumChannels = 17.50; // Dont FORGET PER CHANNEL
// In these three lines we inialized three variables.
// These variables are the Residential prices for some bills.

int Commercial;
// As we did in the previous section of cod, we are declaring the variable for the commercial residents.
const double comProcessingFee = 15.00;
const double comBasicServices = 20.50 ;
// Dont forget about 5.00 for additional connection-- after ten connections.
const double comPremiumChannels = 50.00 ;
// 50.00 per channel for any number of conections.

// We used variable type double becuase we want our answers to be very precise, especially when dealing with money.
// Double types is about 2 times as precise as the variable type floating.

int residential = r and R;
int commercial = c and C;
// Here we are declaring more variables for the program.
// These variables are codes for the customer.

char customerType;
// This is our customer type, we used char because it deals with alhabetical letters.
// The alphabetical leters that this variable is dealing with is ourvariables declared above, which is the customer type.

int premium_channels;
int basic_service_fee;
// In this program, we have potentailly added rates depending on the amount of premium channels for (residents).
// As well as 5.00 service fee for every connection after 10 connections (commercial business).

int customerAccountNum;
double amountDue;
// More variables we must declare.
// Customer account number, so we know its a customer within our branch.
// Also the amount due which is a variable we will need later in the program.

cout << "\tThis program will calculate your NOLA Cable Company bill";
cout << "\tPlease enter your customer account number: ";
cin >> customerAccountNum;
// Here we are asking the customer to enter their account number that consists of four digits.
// If the customer enters >4 or <4 numbers it will be an error and that will be dealt with later in the program.

cout << "\tPlease state rather you are residential or commercial, type r for residential and c for commercial";
cin >> customerType;
// Here we are getting the customer type from the user
// This is either residential or commercial


switch(customerType)
{
case r:
case R:
cout << "\tEnter the number of premium channels ur residancy is subscribed to: ";
cin >> premium_channels;
amountDue = resProcessingFee + resBasicServices + resPremiumChannels * premium_channels;
cout << "\tYour account number: " << customerAccountNum << endl;
cout << "\tYour total amount due is: $" << amountDue << endl;
break;
// I decided to do a switch case because i felt it was slightly easier than doing an if, if else statement.
// In this particular case (residential) we had to calculate the price total by multiplying by the amount
// of premium channels the customer is subscribed too.
// We also had to add the other flat fees, which consisted of processing fee, basic services, and flat charge for premium channels

case c:
case C:
int comConnections;
// Decided to make a new variable to make it more clear as to what number i am recieving from the user.
// The next line asks for the number of connections
cout << "\tEnter number of connections linked to this account: ";
cin >> comConnections;
cout << "\tEnter number of Premium Channels subscribed to: ";
cin >> premium_channels;
// Now that we are on the Commercial calculations we need to get the number connections for basic service fees
// As well as getting the number for the amount of premium channels subscribed too
// These numbers will be incorporated into our if statement

if(comConnections <= 10)
{
amountDue = comProcessingFee + comBasicServices + comPremiumChannels * premium_channels;
cout << "\tYour account number is: " << customerAccountNum << endl;
cout << "\tTotal amount due is: $" << amountDue << endl;
}
else if(comConnections > 10)
{
amountDue = comProcessingFee + comBasicServices + (comConnections - 10)*5 + (premium_channels * comPremiumChannels);
cout << "\tYour account number is: " << customerAccountNum << endl;
cout << "\tYour total amount due is: &" << amountDue << endl;
}
break;

default:
char again;
while(again =='y');

cout << "\tYou did not enter the correct account number, or did not use the correct keys";
cout << "\tDo you want to try again? Y or N";
cin >> again;
}


cin.get();

cin.get();

return 0;
}





You sometimes use r or c or C instead of residential or comercial? Also those are not declarated. Also try to add using namespace std; and see if theres a lot of errors. Im begginner
in my assignment it sais I have to put little c and big C(little r and big R) as options because basically, their is no telling if the customer (user) is going to put in a lowercase letter or not.

one of the main things I did wrong is declaring the letters, I'm confused on that part.

and WOW thank you so much, I cant believe I didn't have that in their!!
though it didn't help much, still cant figure out what the problem is
I working now to remake your code, for finished one add me on skype: CosminPerRam or cosmin.p@live.com and tell me about code!
That would be great although I have never used skype before, how do you add someone?
oh, add me on facebook and message me
https://www.facebook.com/cosmin.patrinjan
anyone who want to troll please dont add me!
I don't want to download skype on my sony, I started having major problems when I downladed windows ten. Until I get a new one, I'm stuck with this one. I been keeping away from any downloads basically. BUT my email is thomaslanda@dcc.edu if you still want to talk and can help me with the coding
Here is your code reformatted and with the compilation errors fixed. I highlighted the parts I changed. or search for "dmh"
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
#include<iostream>

using std::cout;                // dmh
using std::cin;
using std::endl;

int
main()
{
    int resident;  // dmh this is unused
    // Here, I declare resident as a variable (of integer type).
    const double resProcessingFee = 4.50;
    const double resBasicServices = 20.50;
    const double resPremiumChannels = 17.50;    // Dont FORGET PER CHANNEL
    // In these three lines we inialized three variables.
    // These variables are the Residential prices for some bills.

    int Commercial;  // dmh this is unused
    // As we did in the previous section of cod, we are declaring the
    // variable for the commercial residents.
    const double comProcessingFee = 15.00;
    const double comBasicServices = 20.50;
    // Dont forget about 5.00 for additional connection-- after ten
    // connections.
    const double comPremiumChannels = 50.00;
    // 50.00 per channel for any number of conections.

    // We used variable type double becuase we want our answers to be
    // very precise, especially when dealing with money.
    // Double types is about 2 times as precise as the variable type floating.

    //     int residential = r and R;
    //    int commercial = c and C;
    // Here we are declaring more variables for the program.
    // These variables are codes for the customer.

    char customerType;
    // This is our customer type, we used char because it deals with
    // alhabetical letters.
    // The alphabetical leters that this variable is dealing with is
    // ourvariables declared above, which is the customer type.

    int premium_channels;
    int basic_service_fee; // dmh this is unused
    // In this program, we have potentailly added rates depending on
    // the amount of premium channels for (residents).
    // As well as 5.00 service fee for every connection after 10
    // connections (commercial business).

    int customerAccountNum;
    double amountDue;
    // More variables we must declare.
    // Customer account number, so we know its a customer within our branch.
    // Also the amount due which is a variable we will need later in
    // the program.

    cout << "\tThis program will calculate your NOLA Cable Company bill";
    cout << "\tPlease enter your customer account number: ";
    cin >> customerAccountNum;
    // Here we are asking the customer to enter their account number
    // that consists of four digits.
    // If the customer enters >4 or <4 numbers it will be an error and
    // that will be dealt with later in the program.

    cout <<
        "\tPlease state rather you are residential or commercial, type r for re\
sidential and c for commercial";
    cin >> customerType;
    // Here we are getting the customer type from the user
    // This is either residential or commercial

    switch (customerType) {
    case 'r':
    case 'R': // dmh use single quotes to indicate a character constant
        cout << "\tEnter the number of premium channels ur residancy is subscri\
bed to: ";
        cin >> premium_channels;
        amountDue =
            resProcessingFee + resBasicServices + resPremiumChannels * premium_\
channels;
        cout << "\tYour account number: " << customerAccountNum << endl;
        cout << "\tYour total amount due is: $" << amountDue << endl;
        break;
        // I decided to do a switch case because i felt it was
        // slightly easier than doing an if, if else statement.  In
        // this particular case (residential) we had to calculate the
        // price total by multiplying by the amount of premium
        // channels the customer is subscribed too.  We also had to
        // add the other flat fees, which consisted of processing fee,
        // basic services, and flat charge for premium channels

    case 'c':
    case 'C':                   // dmh single quotes again
        int comConnections;
        // Decided to make a new variable to make it more clear as to
        // what number i am recieving from the user.
        // The next line asks for the number of connections
        cout << "\tEnter number of connections linked to this account: ";
        cin >> comConnections;
        cout << "\tEnter number of Premium Channels subscribed to: ";
        cin >> premium_channels;
        // Now that we are on the Commercial calculations we need to
        // get the number connections for basic service fees As well
        // as getting the number for the amount of premium channels
        // subscribed too These numbers will be incorporated into our
        // if statement

        if (comConnections <= 10) {
            amountDue =
                comProcessingFee + comBasicServices +
                comPremiumChannels * premium_channels;
            cout << "\tYour account number is: " << customerAccountNum << endl;
            cout << "\tTotal amount due is: $" << amountDue << endl;
        } else if (comConnections > 10) {
            amountDue =
                comProcessingFee + comBasicServices + (comConnections - 10) * 5\
 +
                (premium_channels * comPremiumChannels);
            cout << "\tYour account number is: " << customerAccountNum << endl;
            cout << "\tYour total amount due is: &" << amountDue << endl;
        }
        break;

    default:
        char again;
        while (again == 'y');

        cout <<
            "\tYou did not enter the correct account number, or did not use the\
 correct keys";
        cout << "\tDo you want to try again? Y or N";
        cin >> again;
    }

    cin.get();

    cin.get();

    return 0;
}


Topic archived. No new replies allowed.