Program C++ Mengisi BBM

Program C++ :

#include <iostream.h>
#include <conio.h>

class BBM{
public:
pilihan();
transaksi();
hasil();

private:
char jenis;
int pilih;
float jumlah, L, rp;};

BBM::pilihan(){
cout << “Pilih Jenis BBM\n”;
cout << “Premium  : P\nSolar    : S\nPertamax : X\n”;}

 

 

BBM::transaksi(){
do{cout << “Masukkan Kode Jenis BBM: “;cin >> jenis;}
while((jenis!=’p’)&&(jenis!=’s’)&&(jenis!=’x’));

cout << “\nJenis Pembelian\n”;
cout << “Liter : 1\nUang  : 2”;

do{cout << “\nMasukkan Kode Jenis Pembelian: “;cin >>pilih;}
while((pilih!=1)&&(pilih!=2));

if (pilih ==1)
{cout << “\nBerapa liter ?\n”;cin >> L;}
else
{cout << “\nWani Piro ? Rp.”;cin >> rp;}}

BBM::hasil(){
if (jenis==’p’&&pilih==1){
for (float a=0;a<=L;a+=0.1){
jumlah = (a+0.1)* 4500;
cout <<“Rp. “<< a+0.1 << ” ===> “<<jumlah<<” Liter”<<endl;}
cout << “Anda harus membayar: Rp.”<<jumlah<<endl;}
else if (jenis==’p’&& pilih==2){
for (float b=0;b<rp;b+=500){
jumlah = (b+500)/ 4500;
cout <<“Rp. “<< b+500 << ” ===> “<<jumlah<<” Liter”<<endl;}
cout << “Anda mengisi: “<<jumlah<<“Liter”<<endl;}

if (jenis==’s’&&pilih==1){
for (float c=0;c<L;c+=0.1){
jumlah = (c+0.1)* 4500;
cout <<“Rp. “<< c+0.1 << ” ===> “<<jumlah<<” Liter”<<endl;}
cout << “Anda harus membayar: Rp.”<<jumlah<<endl;}
else if (jenis==’s’&& pilih==2){
for (float d=0;d<rp;d+=500){
jumlah = (d+500)/ 4500;
cout <<“Rp. “<< d+500 << ” ===> “<<jumlah<<” Liter”<<endl;}
cout << “Anda mengisi: “<<jumlah<<” Liter”<<endl;}

if (jenis==’x’&&pilih==1){
for (float e=0;e<L;e+=0.1){
jumlah = (e+0.1)* 8800;
cout <<“Rp. “<< e+0.1 << ” ===> “<<jumlah<<” Liter”<<endl;}
cout << “Anda harus membayar: Rp.”<<jumlah<<endl;}
else if (jenis==’x’&& pilih==2){
for (float f=0;f<rp;f+=500){
jumlah = (f+500)/ 8800;
cout <<“Rp. “<< f+500 << ” ===> “<<jumlah<<” Liter”<<endl;}
cout << “Anda mengisi: “<<jumlah<<“Liter”<<endl;}}

int main(){
BBM q;
q.pilihan();
q.transaksi();
q.hasil();

return 0;}

Hasil running :

Hasil running mengisi BBM

Hasil running mengisi BBM

 

Posted on April 8, 2011, in Alprog. Bookmark the permalink. 1 Komentar.

  1. alice pngen .....

    wew

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

%d blogger menyukai ini: