Followers

Saturday 2 March 2013

class mini market

// Class Barang Mini Market.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;


class barang {
    private:
        float a,b,c;
    public:
        float x,y;
        barang (float x, float y) //konstruktor
        {a=x;
         b=y;
         cout<<"Harga  : " <<a<<endl;
         cout<<"Jumlah : " <<b<<endl<<endl;
        }
        float hasil()
        {c=a*b;
         return c;
        }

};
char ulang;
int main()
{
    do {
        system("cls");
        cout<<"Penjualan"<<endl;
        cout<<"================="<<endl;
        cout<<"1. Gula"<<endl;
        cout<<"2. Kopi"<<endl;
        cout<<"3. Rokok"<<endl;
        cout<<"4. Roti"<<endl;
        cout<<"5. Kacang"<<endl;
        cout<<"================="<<endl;

        int pilih;
        float jml,hrg;

        cout<<"Pilih : ";
        cin>>pilih;
        cout<<"-----------------------------------"<<endl;
        cout<<"Jumlah: ";
        cin>>jml;
        cout<<"-----------------------------------"<<endl;
        if (pilih==1)
        {hrg=10000;}
        else if (pilih==2)
        {hrg=20000;}
        else if (pilih==3)
        {hrg=30000;}
        else if (pilih==4)
        {hrg=40000;}
        else if (pilih==5)
        {hrg=50000;}



        barang hitung(hrg,jml);
        cout<<"Bayar    : " <<hitung.hasil()<<endl;
        cout<<"================="<<endl;

            if(hitung.hasil()>100000)
            {cout<<"Bonus 1"<<endl;}

        cout<<"================="<<endl;
cout<<endl<<endl;
cout<<"Mau Mencoba Lagi [Y/T] ? "; cin>>ulang;
    }while ((ulang=='y') || (ulang=='Y'));

return 0;
}

TRANSLATE