ahmed0saber

Electric Bill in C++

Nov 5th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     float cmr , pmr , kp , discount;
  6.     int type;
  7.     again:
  8.     cout<<"Enter the current meter reading in kilowatt"<<endl;
  9.     cin>>cmr;
  10.     cout<<"Enter the previous meter reading in kilowatt"<<endl;
  11.     cin>>pmr;
  12.     cout<<"Choose the type of meter by entering 1 or 2"<<endl<<"1.home   2.commercial"<<endl;
  13.     cin>>type;
  14.     if(cmr>pmr&&(type==1||type==2))
  15.     {
  16.         cout<<endl<<"Kilowatt Consumption = "<<cmr-pmr<<endl;
  17.         if(type==1)
  18.         {
  19.             kp=0.5;
  20.         }
  21.         else if(type==2)
  22.         {
  23.             kp=0.6;
  24.         }
  25.         cout<<"Kilowatt Price = "<<kp<<" $"<<endl;
  26.         cout<<"Consumption Cost = "<<kp*(cmr-pmr)<<" $"<<endl;
  27.         cout<<"Value Added Tax (VAT) = "<<kp*(cmr-pmr)*14/100<<" $"<<endl;
  28.         if(type==1)
  29.         {
  30.             if((cmr-pmr)<200)
  31.             {
  32.                 discount=kp*(cmr-pmr)*10/100;
  33.             }
  34.             else if((cmr-pmr)>=200)
  35.             {
  36.                 discount=kp*(cmr-pmr)*15/100;
  37.             }
  38.         }
  39.         else if(type==2)
  40.         {
  41.             if((cmr-pmr)<400)
  42.             {
  43.                 discount=kp*(cmr-pmr)*15/100;
  44.             }
  45.             else if((cmr-pmr)>=400)
  46.             {
  47.                 discount=kp*(cmr-pmr)*20/100;
  48.             }
  49.         }
  50.         cout<<"Discount Amount = "<<discount<<" $"<<endl;
  51.         cout<<"Net Total = "<<(kp*(cmr-pmr))+(kp*(cmr-pmr)*14/100)-discount<<" $"<<endl;
  52.     }
  53.     else
  54.     {
  55.         cout<<"There is an error , Try again..."<<endl<<endl;
  56.         goto again;
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment