Sabtu, 23 April 2011

simulation program to purchase fuel

A#include (iostream.h)
#include (conio.h)

using namespace std;

int main(int argc, char *argv[])
{

class spbu (){
friend ostream& opreator<<(ostream&,spbu&); friend istream& operator>>(istream&,spbu&);
public :
void banyak();
void pilihan();
void hitung_liter();
void hitung_harga();
private :
int harga;
int Biaya;
int a,b ;
float hasil ;
float premium ;
float solar ;
float pertamax ;
};
void banyak::liter(){
cout<<"Masukkan berapa liter yang dibutuhkan : "; cin>>x;
}
void banyak::pilihan(){
cout<<"pilih 1 untuk premium\n"<<<"pilih="" 2="" untuk="" solar\n";
}
void banyak::hitung_liter(){
float i = 0.0;
while(i <= x){
i = i + 0.1;
cout<<i<<endl;
 }
void banyak::hitung_harga(){
float hasil = 0.0;
float premium = 4500;
float solar = 6000;
float pertamax = 8000;
if(y == 1)
hasil = x * premium;
else if(y == 2)
hasil = x * solar;
else if(y == 3)
hasil = x * pertamax;
cout<<"harga : "<<hasil<<endl;
 }
void main(){
spbu :
banyak.banyak();
banyak.harga(); 
banyak.hitung_liter();
banyak.hitung_harga();
system("PAUSE");
return EXIT_SUCCESS;
}

simulation buy fuel with specifications:
Input form:
money / how many liters that will be purchased
Type of fuel to be purchased
Indicators will continue (increasing 0.1liter) for the total price / number of liters of fuel purchased not exceed demand
Output states:
The number of liters purchased (if the input in the form of money)
Total money to be paid (if the input in the form liter).

0 komentar:

Blogger template 'Purple Mania' by Ourblogtemplates.com 2008

Jump to TOP