#include <iostream> // for CableBills
#include <iomanip> // for formatting manipulators
#include <string> // for string variables
#include <fstream> // for file streams
using namespace std;
// Prototype Functions
void PrintHeading(ofstream& CableBills) ; // Inout
void CustomerData(ofstream& CableBills,
ifstream& CableRecs) ; // Inout
int OutletCharge(int) ;
int ServiceCharge(char) ; // Out
// Global Variables
int totalOutlet;
int totalService;
int totalTax;
int totalTotal;
int totalCustomers;
int main()
{
// Declaring Input variables
char accountFirstName; // Account First Name
char accountLastName; // Account Last Names
char accountNumber; // Account Number
char date; // Account Date
int service; // Nominal, Basic, or Premium (14.95, 34.95, 69.95 respectively
int outlets; // Amount of outlets purchased
// Declaring input and output file
ifstream CableRecs;
ofstream CableBills;
CableRecs.open("CableRecs.txt"); // To attach CableRecs file to CableRecs
CableRecs.ignore(100, '\n'); // To ignore the first line of Cable Records
CableBills.open("CableBills.txt"); // The output file
if (!CableRecs) // In case the program can't read the file
{ CableBills << "Unable to read file." << endl;
return 1;
}
// Invoking PrintHeading function - Pass by reference
PrintHeading(CableBills);
// Reading data of the 1st customer (Priming Read)
CableRecs >> accountFirstName;
CableRecs >> accountLastName;
CableRecs >> accountNumber;
CableRecs >> date;
CableRecs >> outlets;
CableRecs >> service;
while (CableRecs) // Loop starts
{
// Invoking OutletCharge
OutletCharge(outlets);
// Invoking ServiceCharge function - Pass by value
ServiceCharge(service);
// Reading values from customer data
CableRecs >> accountFirstName;
CableRecs >> accountLastName;
CableRecs >> accountNumber;
CableRecs >> date;
CableRecs >> outlets;
CableRecs >> service;
} // End of Loop
// Closing input and output files
CableRecs.close();
CableBills.close();
return 0;
}[
int ServiceCharge(char service,
int serviceCharge){
const int NOMINALFEE = 1495; // Charged if customer uses nominal service
const int BASICFEE = 3495; // Charged if customer uses basic service
const int PREMIUMFEE = 6995; // Charged if customer uses premium service
const char NOMINALCODE = "N"; // Customer code for nominal service
const char BASICCODE = "B"; // Customer code for basic service
const char PREMIUMCODE = "P"; // Customer code for premium service
[b]
// Nominal service charges 14.95
if ( service == NOMINALCODE) {
serviceCharge = NOMINALFEE;
}
// Basic service charges 34.95
if ( service == BASICCODE ) {
serviceCharge = BASICFEE;
}
// Premium service charges 69.95
if ( service == PREMIUMCODE ) {
serviceCharge = PREMIUMFEE;
[/b]}
return serviceCharge;
}
The purpose of this program is to read a data set of customers purchasing cable service and then calculating it out into order to make a transaction report in the end.
The problem I'm having is these error code come up when I try to run it.
(181): error C2440: 'initializing' : cannot convert from 'const char [2]' to 'const char'
(182): error C2440: 'initializing' : cannot convert from 'const char [2]' to 'const char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
(183): error C2440: 'initializing' : cannot convert from 'const char [2]' to 'const char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
It points out to the bool coding on the ServiceCharge function.