Question 1 The electricity bills of customers are calculated as follows: 10 Marks
Expert Answer
- Comment
SOLUTION-
I have solve the problem in C++ code with comments and screenshot for easy understanding :)CODE-
#include<stdio.h>
float ElectricityCost(float units)
{
float bill;
if(units<500)
bill = 5 + 0.02*units;
else
bill = 15 + 0.05*(units-500);
return bill;
}int main()
{
float units,bill;
while(true){
printf("Enter number of units consumed : ");
scanf("%f",&units);
if(units<0)
break;
bill = ElectricityCost(units);
printf("Total bill : %f JD\n\n",bill);
}
return 0;
}
SCREENSHOT-
IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK YOU!!!!!!!!----------
ليست هناك تعليقات:
إرسال تعليق