/* Write a program to input the number of units of electricity consumed
in a house and calculate the final amount using nested-if statement. use
the following data for calculation
Units consumed Cost
<30 Rs 3.50/unit
>=30 and <50 Rs 4.25/unit
>=50 and <100 Rs 5.25/unit
>100 Rs 5.85/unit */
#include<iostream.h>
#include<conio.h>
void main()
{
int oldread,newread,units;
float minamt,vat,amt,netamt;
clrscr();
cout<<"Enter the old reading: ";
cin>>oldread;
cout<<"Enter the new reading: ";
cin>>newread;
cout<<"Enter the minimum amount: ";
cin>>minamt;
units=newread-oldread;
if(units<30)
amt=units*3.50;
else if(units<50)
amt=(29*3.50)+(units-29)*4.25;
else if(units<100)
amt=(29*3.50)+(20*4.25)+(units-49)*5.25;
else
amt=(29*3.50)+(20*4.25)+(50*5.25)+(units-99)*5.85;
vat=12.5/100;
netamt=amt+(amt*vat)+minamt;
cout<<"Final amount="<<netamt;
getch();
}

No comments: