Answer to Question #16766 in C++ for Hania

Question #16766
write a program to calculate electricity bill. if the units consumed are equal or less 100 then the cost of per unit is 5,if units consumed are more than 100 and less than 200 then the cost is 7 per unit and if units consumed are more than 200 then the cost is 9 per unit
1
Expert's answer
2012-10-23T09:16:14-0400
#include<iostream.h>

int U;
float C;

void main(){

cout<<"Consumed units: ";
cin>>U;
if (U<=100) C = 5*(float)U;
if ((U>100)&&(U<=200)) C = 7*(float)U;
if (U>200) C = 9*(float)U;
cout<<"Price: "<<C<<"\n";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS