Error codes.

This is what I'm trying to do:

Your new cell bill program must use 3 functions with parameters, as follows:

function calcRegBill – accepts one integer argument for the number of minutes used. Determines and returns the total amount due.
function calcPremBill – accepts two integer arguments, for the number of day minutes and number of night minutes used. Determines and returns the total amount due.
function printBill – accepts 4 arguments: a string account number, a character service code, an integer total number of minutes used, and an amount due. Note that this is a generic print bill function, which prints either a regular or premium bill.

This is what I have so far:

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

//Program Assignment 9
//Author:
//Date: 4/13/2015
//This program is used to collect phone bill data and calculate a total monthly phone bill.

#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <string>

using namespace std;
double calcRegBill(int z);
double calcPremBill (int a, int b);
void printBill (string a, char s, int tm, int ta);

int main ()
{
    double dayMinutes, nightMinutes, anyMinutes;
    int total;
    string account;
    char servicePlan;

    cout << "Enter the first letter of your service plan: " ;
    cin >> servicePlan;
    cout << "Enter your 4 digit account number: " ;
    cin >> account;
    cout << endl;

    switch (servicePlan)

{
   case 'R':
   case 'r':

        cout << "Enter the number of anytime minutes used: " ;
        cin >> anyMinutes;
        anyMinutes = anyMinutes - 50;
        cout << endl;

 calcRegBill (anyMinutes);
 printBill (account, servicePlan, anyMinutes, total);

   case 'P':
   case 'p':

        cout << "Enter the number of daytime minutes used: " ;
        cin >> dayMinutes;
        dayMinutes = dayMinutes - 75;
        cout << endl;

        cout << "Enter the number of night time minutes used: " ;
        cin >> nightMinutes;
        nightMinutes = nightMinutes - 100;
        cout << endl;

calcPremBill (dayMinutes, nightMinutes);
printBill (account, servicePlan, anyMinutes, total);
}
}

    double calcRegBill(int z)
{
    double total;
    if (z > 0)
        total = 10 + z * .2 << endl;
    else
        total = 10 << endl;
    break;
}

    double calcPremBill (int a, int b)
{
    int total;
    int totalMinutes;
        cout << "Enter the number of daytime minutes used: " ;
        cin >> a;
        cout << endl;

        cout << "Enter the number of night time minutes used: " ;
        cin >> b;
        cout << endl;
    a = a - 75;
    b = b - 100;

    if (a > 0 && b > 0)
          totalMinutes = a + b;
          total = (25 + (a * .1) + (b * .05)) << endl;
    else if (a <= 0 && b > 0)
          totalMinutes = a + b;
          total = (25 + (b * .05)) << endl;
    else if (a > 0 && b <= 0)
          totalMinutes = a + b;
          total = (a * .1) << endl;
    else
          total = 25 << endl;
}

void printBill (string a, char s, int tm, int ta)
 {
    if (s == 'r' or 'R')
 {
    cout << "Creator: Paul Vellake" << endl;
    cout << "Date: 4/13/15" << endl;
    cout << "Account Number: " << a << endl;
    cout << "Service Type: Regular" << endl;
    cout << "Total Minutes: " << tm << endl;
    cout << "Amount Due: $" << ta << endl;
 }
    else
    cout << "Creator: Paul Vellake" << endl;
    cout << "Date: 4/13/15" << endl;
    cout << "Account Number: " << a << endl;
    cout << "Service Type: Premium" << endl;
    cout << "Total Minutes: " << tm << endl;
    cout << "Amount Due: $" << ta << endl;
 }



HERE ARE THE ERRORS

In function 'double calcRegBill(int)':|
|66|error: invalid operands of types 'double' and '<unresolved overloaded function type>' to binary 'operator<<'|
|68|error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'|
In function 'double calcPremBill(int, int)':|
|86|error: invalid operands of types 'double' and '<unresolved overloaded function type>' to binary 'operator<<'|
|88|error: invalid operands of types 'double' and '<unresolved overloaded function type>' to binary 'operator<<'|
|90|error: invalid operands of types 'double' and '<unresolved overloaded function type>' to binary 'operator<<'|
|92|error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'|
||=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


Last edited on
Please edit your post and use [code]code tags[/code] for all of your code - http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
Your problem, most likely, lies in statements that resemble this (You do it several times throughout your code):

total = (25 + (b * .05)) << endl;

You're appending the stream insertion operator, complete with endline, to an assignment statement. My guess is that you had done some find/replace that went haywire. However, if you purposefully typed the aforementioned statement, you'll be dismayed to know that you cannot insert stream data into an arithmetic expression and assign the result to a variable.

Kindest regards.
Note: I didn't understand your formulas to calculate the bill. Why did you have to deduct minutes (line 38, 49, and 54). They could result in negative numbers.

I didn't do input validations after user enters values. Input validation is strongly recommended in order to run the program, smoothly and bug-free.

Anyway, This is how I would do [Keeping the formulas same as yours, except the above mentioned deduction parts]

Happy coding...

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
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

double calcRegBill (int totalMinutes);
double calcPremBill (int dayMinutes, int nightMinutes);
void printBill (string accNumber, char serviceCode, int totalMinutes, double amountDue);

int main ()
{
    int totalMinutes (0);
    double amountDue (0.00);
            
    string accNumber (" ");
    cout << "Enter your 4 digit account number: ";
    getline (cin, accNumber);

    char serviceCode (' ');
    cout << "Enter the first letter of your service plan: " ;
    cin >> serviceCode; 
    
    if (serviceCode == 'r' || serviceCode == 'R')
    {
        cout << "Enter the number of anytime minutes used: " ;
        cin >> totalMinutes;
        
        amountDue = calcRegBill (totalMinutes);
    }
    
    
    if (serviceCode == 'p' || serviceCode == 'P')
    {
        int dayMinutes (0);
        cout << "Enter the number of daytime minutes used: " ;
        cin >> dayMinutes;
        
        int nightMinutes (0);
        cout << "Enter the number of night time minutes used: " ;
        cin >> nightMinutes;
                
        amountDue = calcPremBill (dayMinutes, nightMinutes);
        
        totalMinutes = dayMinutes + nightMinutes;
    }
    printBill (accNumber, serviceCode, totalMinutes, amountDue);
    
    return 0;
}



double calcRegBill (int totalMinutes)
{
    double amountDue (10.00);
    
    if (totalMinutes > 0)
        amountDue += totalMinutes * 0.2;   
    
    return amountDue;
}



double calcPremBill (int dayMinutes, int nightMinutes)
{
    double amountDue (25.00);
    
    if (dayMinutes > 0 && nightMinutes > 0)
        amountDue += (dayMinutes * 0.1) + (nightMinutes * 0.05);
        
    else if (dayMinutes <= 0 && nightMinutes > 0)
        amountDue += nightMinutes * 0.05;
    
    else if (dayMinutes > 0 && nightMinutes <= 0)
        amountDue += dayMinutes * 0.1;
                  
    return amountDue;
}



void printBill (string accNumber, char serviceCode, int totalMinutes, double amountDue)
{
    cout << "\nCreator: Paul Vellake" << endl;
    cout << "Date: 4/13/15" << endl;
    cout << "Account Number: " << accNumber << endl;
    
    if (serviceCode == 'r' || serviceCode == 'R')
        cout << "Service Type: Regular" << endl;
    
    else cout << "Service Type: Premium" << endl;
    
    cout << "Total Minutes: " << totalMinutes << endl;
    cout << fixed << setprecision(2) << "Amount Due: $" << amountDue << endl;
 }
 
Topic archived. No new replies allowed.