Question

2. PRACTICAL ASSIGNMENT 2 2.1 Covert the following design into C++. Refer to figure 1 for sample output. Save your source file as runProgram1.cpp. Indude your student number, suname and initials and group at the beginning of the source files as comments. Submit anly the C++ source file. DoBlectricityCalcalations custMom <> 99999 display Enter the leotricity usage in kilowatt-hours Call the anntoving Calohntowing (usage) Cali the aub procedure display EnteE the oustoner nusbeE 199999 to end display The total uaage for li customers istotalosage if valusage200 then anntovingval0sage 2.70 DS017AT anntouing 2002.70valUsage-200) 1.60 return anntowing nter the electricity usage in kilowatt-hours: 75.18

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the solution to your problem let me know if you have any concerns.

#include<iostream>
using namespace std;

//declation of methods.
void incrementCounterTotals(float valAmountOwing, float refTotalUsage, int refNumCost);
float calcAmntOwing(float valUsage);

//main class

int main(){
float totalUsage =0;
int numCustomers =0;
cout<<"Enter the customer numer (9999 to end)"<< endl;
int custNum;
cin>>custNum;
do{
cout<<"Enter the eletricity usage in kilowatt- hours" << endl;
float usage;
cin>>usage;
float amntOwing = calcAmntOwing(usage);

incrementCounterTotals(usage,totalUsage,numCustomers);
cout<<"The amount owing for customer "<<custNum<<"is "<<amntOwing<<endl;
cout<<"Enter the customer numer (9999 to end)"<< endl;
cin>>custNum;
}
while (custNum!=9999);
return 0;
}

float calcAmntOwing(float valUsage){
float amntOwing = 0;
if (valUsage <= 200)
amntOwing = valUsage * 2.70;
else
amntOwing = 200 *2.70 + (valUsage - 200) * 1.60;
  
return amntOwing;
}


void incrementCounterTotals(float valAmountOwing, float refTotalUsage, int refNumCost){
refTotalUsage = refTotalUsage + valAmountOwing;
refNumCost = refNumCost + 1;
}

Add a comment
Know the answer?
Add Answer to:
2. PRACTICAL ASSIGNMENT 2 2.1 Covert the following design into C++. Refer to figure 1 for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT