Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the below program to store the customer number and kilowatt-hours in arra

ID: 3621385 • Letter: M

Question

Modify the below program to store the customer number and kilowatt-hours in arrays.
As you input the customer number and usage in kilowatt-hours store those values in parallel array positions. After all data has been read then use a for loop to sequence through the arrays computing each customer’s amount due and printing the customer number, usage and amount due.

The output should be in tabular form as shown below.

Customer Usage in Amount Due(dollars)
Number KWH _______________________
1231 400 68.00
3431 600 88.00
xxxxx (remainder of output table)
_________________________________________
Total xxxxx xxx.xx
Average xxx.x xxx.xx


THE PROGRAM TO BE MODIFIED:

// Electricity Cost Program
#include < iostream >
using namespace std;
//function prototype
double computeCharge(double kilowatts);

int main()
{
double kilowatts, charge;
int id;
char choice;
do
{
cout<<"Enter Customer id:";
cin>>id;
if(id<1000)
{
cout<<"Invalid Enter Customer id:";
cin>>id;
}

// data input
cout << "Enter the kilowatt-hours used: ";
cin >> kilowatts;
//function call to compute
charge=computeCharge(kilowatts);
// display the result
cout.setf(ios::fixed | ios::showpoint);
cout.precision(2);
cout << "The charge for " << kilowatts
<< " kilowatt-hours is $"
<< charge<< endl;
cout<<"Do you wish to compute for another customer:";
cin>> choice;

}while(choice=='y');
system("pause");
return 0;
}
double computeCharge(double kilowatts)
{
double charge;
// calculate charge for kilowatts-hours
if(kilowatts > 1500)
charge = 0.12*400 + 0.1*600 + 0.08*500+ 0.06*(kilowatts - 1500);
else if (kilowatts > 1000)
charge = 0.12*400 + 0.1*600 + 0.08*(kilowatts - 1000);
else if (kilowatts > 400)
charge = 0.12*400 + 0.1*(kilowatts - 400);
else
charge = 0.12*kilowatts;
return charge+20;
}

Explanation / Answer

Dear, Here is the modified code with arrays // Electricity Cost Program #include using namespace std; //function prototype double computeCharge(double kilowatts); int main() { double kilowatts[10], charge[10]; int id[10]; int num; int i=0; coutnum; do { coutid[i]; if(id[i] kilowatts[i]; //function call to compute charge[i]=computeCharge(kilowatts[i]); // display the result cout.setf(ios::fixed | ios::showpoint); cout.precision(2); cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote