Line 5: You're missing
using namespace std
. It's better practice to leave it out, but if you do so, every reference to the standard library library must be qualified by std::
line 79,84: C++ does not support implied left hand side in conditionals. You must fully specify the conditions.
Example:
if (ans == 'Y' || 'y')
evaluates as
if ((ans == 'Y') || ('y'))
('y')
always evaluates to 1 (
true
), therefore the if statement is always true.
Line 87: The order of your parameters is incorrect. According to your function prototype, basicServNum precedes customerID.
Line 108: calcCustRes() is declared type void, but you're trying to return a value (1).
Line 117-120: Break into two statements, or use () to isolate the calculation.
1 2 3 4
|
amountDue = resBillProc
+ resBasicServCost
+ (premiumChanNum[i][3]) * resCostPremChan;
outFile << "Bill: $" << amount_due << endl << endl;
|
Line 136: calcCustBus() is declared type void, but at line you're trying to return a value.
Line 23, 87, 124: You're inconsistent in your use of customerID. The function prototype and the function say they accept a simple string. But when you call calcCustBus(), you pass an array.
That's it for syntax errors. You have a number of logical errors also.
Line 48: You're assuming there are exactly 20 customers in the file. Your assignment did not specify how many there would be, only that there would be at least 15. You should use a while loop, continuing until a read fails.
1 2 3 4
|
while (inFile >> customerID[i])
{ // Got a good customerID
...
}
|
line 51,53,55: infile.get() is unnecessary to remove whitespace if you use the >> operator.
|
inFile >> customerType[i];
|
Line 52,54,56: These are out of bounds references. customerType is declared as char[][2], meaning the elements are [0]-[1].
Line 81,86: calcCustRes() and calcCustBus() should really be designed to calculate a single customer rather than passing them the all the parallel arrays.
Have you covered structs yet? They are much clearer than parallel arrays.
1 2 3 4 5 6 7
|
struct customer
{ string customerID;
char customerType;
int premiumChanNum;
int basicServNum;
};
customer customers[MAX_CUSTOMERS];
|
Line 91: You close the outfile, but never opened it or used it in main().
Lines 100, 128: You prompt for output file name every time you call calcCustRes or calcCustBus. That's going to be very repetitive entering that for each customer in the input file.