Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add arrays for data / implement the use of arrays And I need help with the flow chart as well please! Rewrite the Programming Example

image text in transcribed image text in transcribed image text in transcribed image text in transcribed image text in transcribed image text in transcribed Add arrays for data / implement the use of arrays And I need help with the flow chart as well please!

Rewrite the Programming Example page 236 in chapter 4 ( Cable Company Billing ). Expected Program and Design: 1. Write a pseudo code before starting your program ( do not use SWITCH, replace it with IF structures ) 1.1 Draw a flowchart for your program based on your pseudo code 2. Identify your constants 3. Your input will come from a text file of at least 15 customers 3.1 Input file format - customerType accountNumber premiumChannels ( i.e residential example: R12345 5 , business example B12345 16 8 ) 4. Precision should be two decimal places 5. Calculate the running average for residential and business customer spending 6. Print all customer's bill to a single file and the end of the file you should have the average summary for each customer type. 6.1 Pay attention to details when you formatting your output

Note: Use all chapter concepts and make your final as a true representation of what we have learned this semester. Turn in program design ( pseudo code and/or flow chart ) input file output file .cpp file of your program ( make sure you include your header and comment your code ) Extra credit Implement your program using arrays, covered in chapter 8, and user defined simple data types to hold customer data. THIS IS THE CODE THATS ALREADY BEEN REWRITTEN FROM THE BOOK. Just need it implemented into arrays and flowchart

#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 business 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()

{

//Variable declaration

int accountNumber;

char customerType;

int numOfPremChannels;

int numOfBasicServConn;

double amountDue;

int rescount = 0, buscount = 0;

double ressum = 0.00, bussum = 0.00;

double resavg, busavg;

ifstream fin;

ofstream fout;

//open input file

fin.open("input.txt", ios::in);

if (fin.fail())

{

cout

exit(0);

}

//open ouput file

fout.open("output.txt", ios::out);

fout

fout

fout

//read from input file

while (!fin.eof())

{

//read customer type from file

fin >> customerType;

//read account number from file

fin >> accountNumber;

//If customer type is residential

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

{

//read number of prem channels from file

fin >> numOfPremChannels;

amountDue = RES_BILL_PROC_FEES + RES_BASIC_SERV_COST + numOfPremChannels * RES_COST_PREM_CHANNEL;

//write into output file

fout

fout

//compute running average of residential cusomer's amount due

rescount += 1;

ressum += amountDue;

resavg = ressum / rescount;

}

//If customer type is business

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

{

//read number of service connection from file

fin >> numOfBasicServConn;

//read number of prem channels from file

fin >> numOfPremChannels;

if (numOfBasicServConn

amountDue = BUS_BILL_PROC_FEES + BUS_BASIC_SERV_COST + numOfPremChannels * BUS_COST_PREM_CHANNEL;

else

amountDue = BUS_BILL_PROC_FEES + BUS_BASIC_SERV_COST + (numOfBasicServConn - 10) * BUS_BASIC_CONN_COST + numOfPremChannels *BUS_COST_PREM_CHANNEL;

fout

fout

//compute running average of business cusomer's amount due

buscount += 1;

bussum += amountDue;

busavg = bussum / buscount;

}

else

fout

}

fout

fout

fin.close();

fout.close();

return 0;

}

thats the code. Chapter 8 was about Arrays and Strings I just can't implement it into arrays i'm stuck.

the assert statements. Therefore, the logical choice is to keep these statements but to disable them. You can disable assert statements by using the following preprocessor directive: define NDEBUG This preprocessor directive #define NDEBUG must be placed before the directive #include . ROGRAMMING EXAMPLE: Cable Company Billing This programming example demonstrates a program that calculates a customer's bill for a local cable company. There are two types of customers: residential and business. There are two rates for calculating a cable bill: one for residential customers and one for business customers. For residential customers, the following rates apply atch Video the following ates apply: . Bill processing fee: $4.50 .Basic service fee: $20.50 Premium channels: $7.50 per channel

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions