Help with error invalid operands

I am getting an error in my program that I am writing, and I am not sure how to go about fixing it. The error is on line 42, invalid operands of types 'const char[2]' and 'const char[14]' to binary 'operator<<' any help would be appreciated.

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

double compALocalCharge(double);
double compALongDisCharge(double);
double compBLocalCharge(double&);
double compBLongDisCharge(double&);

int main()
{
    ifstream inputFile;
     
    inputFile.open("E:/CSC_133/lab6data.dat"); //Opens input file
   	 
   //Declare Variables 
  double monthlyRateA = 10.00;//The monthly rate for service for company A
  double monthlyRateB = 7.00; //The monthly rate for service for company B
  double phoneNum;
  char code;
  double localMin;
  double longDistMin;
  double totalCharges; //total from local and long distances charges added togather
  double subtotalA; //all total charges added together for company A
  double subtotalB; //all total charges added together for company B
  double grandTotal; //all subtotals added together
  
  //cout<<fixed;
  //cout<<showpoint;
  //cout<<setprecision(2);
  
  cout<<"Telephone Number"<<"\t"<<"Telephone Code"<<"\t"<<"Local Charges"<<"\t"<<"Long Distance Charges"<"\t"<<"Total Charges"<<endl;
  while(inputFile)
  {
                  inputFile>>phoneNum;
                  cout<<phoneNum;
                  inputFile>>code;
                  cout<<"\t"<<"\t"<<code;
                  
                  if (code == 'A')
                    {  
                         totalCharges = 0;
                         totalCharges = totalCharges + monthlyRateA;
                         inputFile>>localMin;
                    
                         totalCharges = totalCharges + compALocalCharge(localMin);
                         
                         inputFile>>longDistMin;
                         
                         totalCharges = totalCharges + compALongDisCharge(longDistMin);
                           
                          subtotalA = subtotalA + totalCharges;                         
                                                  
                    }
                  else if (code == 'B')
                    {
                      totalCharges = 0;
                      totalCharges = totalCharges + monthlyRateB;
                      inputFile>>localMin;
                          
                      totalCharges = totalCharges + compBLocalCharge(localMin);
                      
                      inputFile>>longDistMin;
                      
                      totalCharges = totalCharges + compBLongDisCharge(longDistMin);
                      
                      subtotalB = subtotalB + totalCharges;
                    }
                    
                    
                    
   cout<<"\t"<<subtotalA; 
   cout<<"\t"<<subtotalB;                
  grandTotal = subtotalA + subtotalB;
  cout<<"\t"<<"\t"<<"\t"<<grandTotal;
                     
  }
   
     system ("pause");
     return 0; 
} // End of main function

double compALocalCharge(double local)
{
        double monthlyCharge;  
    if (local <= 60.0)
       {
                 double monthlyCharge = 0.0;
                 monthlyCharge = monthlyCharge + 0.0;
                 cout<<"\t"<<"0.00";
       }
    else if (local > 60.0)
         {
            double monthlyCharge;
            monthlyCharge = (local - 60.0) * 0.25;
            cout<<"\t"<<monthlyCharge;
         }
         return monthlyCharge;
}
double compALongDisCharge(double longDistance)
{
       double monthlyCharge;
    if (longDistance <= 100.0)
       {  
          double monthlyCharge;
          monthlyCharge = longDistance * 0.20;
          cout<<"\t"<<monthlyCharge;
       }
    else if (longDistance > 100.0)
         {
            double monthlyCharge;
            monthlyCharge = (100.0 * 0.20) + ((longDistance - 100.0)*0.17);
            cout<<"\t"<<monthlyCharge;
         }
return monthlyCharge;
}

double compBLocalCharge(double& localMin)
{
       double monthlyCharge;
    if(localMin <= 30.0)
      {
                double monthlyCharge;
                monthlyCharge = monthlyCharge + 0.0;
                cout<<"\t"<<"0.00";
      }
      else if( localMin > 30.0)
        {
               double monthlyCharge;
               monthlyCharge = (localMin - 30.0)*0.20;
               cout<<"\t"<<monthlyCharge;
        } 
    return monthlyCharge;
}

double compBLongDistanceCharge(double& longDistMin)
{ 
       double monthlyCharge;
    if (longDistMin <= 200.0)
       {
                   double monthlyCharge;
                   monthlyCharge = (longDistMin * 0.25);
                   cout<<"\t"<<monthlyCharge;
       }
    else if (longDistMin > 200.0)
         {  
            double monthlyCharge;
            monthlyCharge= (200.0 * 0.25) + ((longDistMin - 200.0)* 0.18);
            cout<<"\t"<<monthlyCharge;
            }
 return monthlyCharge;        
}
There's a single < that should be a <<

cout<<"Telephone Number"<<"\t"<<"Telephone Code"<<"\t"<<"Local Charges"<<"\t"<<"Long Distance Charges"<"\t"


You'll also need to fix the discrepancy in function name if these are supposed to be the same function.

1
2
double compBLongDisCharge(double&);
double compBLongDistanceCharge(double& longDistMin)

Last edited on
Well I feel pretty foolish for missing that, thank you for the help.
Topic archived. No new replies allowed.