Question: Do in MIPS-Mars 4_5. The following code is C++. Please make sure there are comments and try to run it. Thank you. #include #include #include

Do in MIPS-Mars 4_5. The following code is C++. Please make sure there are comments and try to run it. Thank you.

#include

#include

#include

#include

using namespace std;

//named constants - residential customers

const double RES_BILL_PROC_FEES = 4.50;

const double RES_BASIC_SERV_COST = 20.50;

const double RES_COST_PREM_CHANNEL = 7.50;

//named constants - bussiness customers

const double BUS_BILL_PROC_FEES = 15.00;

const double BUS_BASIC_SERV_COST = 75.00;

const double BUS_BASIC_CONN_COST = 5.00;

const double BUS_COST_PREM_CHANNEL = 50.00;

int main()

{

//varible declaration

int accountNumber;

int numOfPremChannels;

int numOfBasicServConn;

int countBillOfResidential = 0;

int countBillOfBussiness = 0;

double amountDue = 0.00;

double totalAmountResidential = 0.00;

double totalAmountBussiness = 0.00;

char customerType;

//read the file

ifstream inFile;

inFile.open("data.txt");

//check the input file exist

if(inFile.fail())

{

cout << "The file doesn't exist!" <

exit(1);

}

//create and write to another file

ofstream outFile;

outFile.open("Billing.txt");

outFile << fixed << showpoint;

outFile << setprecision(2);

outFile << "Customer Type" << setw (20) << "Account Number"

<< setw(35) << "Number of Service Connection"

<< setw(25) << "Number of Channel"

<< setw(20) << "Amount Due" << endl;

outFile << "----------------------------------------------------------------------------------------------------------------" <

while(!inFile.eof())

{

inFile >> customerType >> accountNumber >> numOfBasicServConn >> numOfPremChannels;

if (customerType == 'R' || customerType == 'r')

{

amountDue = RES_BILL_PROC_FEES + RES_BASIC_SERV_COST + (numOfPremChannels * RES_COST_PREM_CHANNEL);

outFile << "Residential"

<< setw(17) << accountNumber

//<< setw(27) << numOfBasicServConn

<< setw(55) << numOfPremChannels

<< setw(22) << "$" << amountDue <

countBillOfResidential++;

totalAmountResidential += amountDue;

}

else if (customerType == 'B' || customerType == 'b')

{

amountDue = 0.00;

if(numOfBasicServConn <= 10)

{

amountDue = BUS_BILL_PROC_FEES + BUS_BASIC_SERV_COST + (BUS_COST_PREM_CHANNEL * numOfPremChannels);

}

else

{

amountDue = BUS_BILL_PROC_FEES + BUS_BASIC_SERV_COST

+ ((numOfBasicServConn - 10) * BUS_BASIC_CONN_COST) + (BUS_COST_PREM_CHANNEL * numOfPremChannels);

}

outFile << "Bussiness"

<< setw(19) << accountNumber

<< setw(27) << numOfBasicServConn

<< setw(28) << numOfPremChannels

<< setw(22) << "$" << amountDue <

countBillOfBussiness++;

totalAmountBussiness += amountDue;

}

else

{

outFile << "Invalid Customer Type!" <

}

}

outFile << endl;

outFile << "SUMMARY INFORMATION" << endl;

outFile << "----------------------------------------------------------------------------------------------------------------" <

outFile << "Customer Type" << setw (20) << "Number of Bill"

<< setw(20) << "Total Amount"

<

outFile << "----------------------------------------------------------------------------------------------------------------" <

outFile << "Residential" << setw(16) << countBillOfResidential

<< setw(17) << "$" << totalAmountResidential

<< setw(15) << "$" << totalAmountResidential / countBillOfResidential << endl;

outFile << "Bussiness" << setw(18) << countBillOfBussiness

<< setw(17) << "$" << totalAmountBussiness

<< setw(14) << "$" << totalAmountBussiness / countBillOfBussiness << endl;

inFile.close();

outFile.close();

cout << "Waiting for computing." << endl;

return 0;

}

Here is the input file name data.text

B12345 16 4 R44212 0 3 B22314 12 5 R23341 0 2 B84772 8 1 B74682 5 2 R87864 0 4 R74621 0 11 B33123 10 7 B53622 7 4 R49124 0 8 B78747 15 5 R67232 0 14 R23427 0 4 B37834 7 12

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!