Advertisement
khisby

[Soal9]Bills_city_power

Oct 9th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. // Khisby Al Ghofari, 06.2017.1.06852, Kelas B
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int consumption;
  9.     float bill;
  10.     char user,ph;
  11.     cout << "\n====================================\n";
  12.     cout << "Welcome To \n";
  13.     cout << "Application Calculate Bills City Power\n";
  14.     cout << "======================================\n \n";
  15.  
  16.     cout << "Code City Power User : \n";
  17.     cout << "R = Residential\n";
  18.     cout << "C = Commercial\n";
  19.     cout << "I = Industrial\n";
  20.     cout << "\nEnter the code user : ";
  21.     cin >> user;
  22.  
  23.     if(user == 'r'|| user == 'R'){
  24.         cout << "Input your consumption power (kwh) : ";
  25.         cin >> consumption;
  26.         bill = consumption*(0.052+6.00);
  27.     }else if(user == 'c' || user == 'C'){
  28.         cout << "Input your consumption power (kwh) : ";
  29.         cin >> consumption;
  30.         if(consumption <= 1000){
  31.             bill = 60.00;
  32.         }else{
  33.             bill = (consumption-1000)*0.045+6.00;
  34.         }
  35.     }else if(user == 'i' || user == 'I'){
  36.         cout << "Enter P for Peak Hours, Enter O for Off-Peak Hours Consumption : ";
  37.         cin >> ph;
  38.  
  39.         if(ph == 'o' ||  ph == 'O'){
  40.             cout << "Enter Off-Peak Hours consumption:";
  41.             cin >> consumption;
  42.  
  43.             if(consumption <= 1000){
  44.                 bill = 40.00;
  45.             }else{
  46.                 bill = (consumption-1000)*0.028+40.00;
  47.             }
  48.         }else if(ph == 'p' || ph == 'P'){
  49.             cout << "Enter Peak Hours consumption :";
  50.             cin >> consumption;
  51.  
  52.             if(consumption <= 1000){
  53.                 bill = 76.00;
  54.             }else{
  55.                 bill = (consumption-1000)*0.065+76.00;
  56.             }
  57.         }else{
  58.             cout << "Your input is invalid";
  59.             return 0;
  60.         }
  61.  
  62.     }else{
  63.         cout << "Your input is invalid";
  64.         return 0;
  65.     }
  66.  
  67.     cout << "The amount due is " << bill;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement