twitter


#include <cstdlib>
#include <iostream>

using namespace std;
class bbakar {
      public:

             bbakar();
             void cetak();
             double proses();
      private :
              double p,q,r,premium,pertamax;
              };
      bbakar::bbakar(){
                       cout<<"SIMULASI MEMBELI BAHAN BAKAR"<<endl;
                       cout<<endl;
                       }
void bbakar::cetak(){
     cout<<"pilih bahan bakar"<<endl;
     cout<<"1.premium"<<endl;
     cout<<"2.pertamax"<<endl;
     cout<<endl;
     cout<<"pilihan : ";cin>>q;
     cout<<endl;
     cout<<"masukan jumlah uang/liter : ";cin>>p;
     }
double bbakar::proses(){
       premium=7000,pertamax=10500;
       if (q==1){
                 if (p<=100){
                             r=p*premium;
                             cout<<"harga"<<p<<"liter bahan bakar : "<<r<<endl;
                             cout<<endl;
                             }
                             else if (p>100){
                                  r=p/premium;
                                  cout<<"jumlah liter yang di beli : "<<p<<"="<<r<<endl;
                                  cout<<endl;
                                  }
                                  }
                                  else if (q==2){
                                       if(p<=100){
                                                  r=p*pertamax;
                                                  cout<<"harga "<<p<<"liter bahan bakar : "<<p<<endl;
                                                  cout<<endl;
                                                  }
                                                  else if (p>100){
                                                       r=p/pertamax;
                                                       cout<<"jumlah liter di yang beli : "<<p<<endl;
                                                       cout<<endl;
                                                       }
                                                       }
                                                       else {
                                                            cout<<"maaf salah memasukkan "<<endl;
                                                            }
                                                            }
            
int main(int argc, char *argv[])
{
    bbakar x;
    x.cetak();
    x.proses();
   
    system("PAUSE");
    return EXIT_SUCCESS;
}


Hasilnya :






0 komentar:

Posting Komentar