using namespace std;
int main()
{
int bbm,harga,diskon,total;
char a;
cout<<"Program Penentuan Harga Setelah di Diskon\n"<<endl;
cout<<"[1] Diskon 10%\n"<<endl;
cout<<"[2] Diskon 20%\n"<<endl;
cout<<"[3] Diskon 30%\n"<<endl;
cout<<"[4] Diskon 40%\n"<<endl;
cout<<"[5] Diskon 50%\n"<<endl;
cout<<"[6] Diskon 60%\n"<<endl;
cout<<"[7] Diskon 70%\n"<<endl;
cout<<"[8] Diskon 80%\n"<<endl;
cout<<"[9] Diskon 90%\n"<<endl;
cout<<"Masukan Pilihan Diskon Yang anda inginkan : ";cin>>bbm;
do{
switch(bbm)
{
case 1 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.1;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 10% adalah :"<<total<<endl;
break;
case 2 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.2;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 20% adalah:"<<total<<endl;
break;
case 3 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.3;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 30% adalah:"<<total<<endl;;
break;
case 4 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.4;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 40% adalah:"<<total<<endl;
break;
case 5 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.5;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 50% adalah:"<<total<<endl;
break;
case 6 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.6;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 60% adalah:"<<total<<endl;
break;
case 7 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.7;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 70% adalah:"<<total<<endl;
break;
case 8 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.8;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 80% adalah:"<<total<<endl;
break;
case 9 :
cout<<"\nMasukan Harga Dasar BBM:";cin>>harga;
diskon=harga*0.9;
total=harga-diskon;
cout<<"\nHarga Setelah di Diskon 90% adalah:"<<total<<endl;
}
cout<<"tekan 'y' jika ingin mengulang :";
cin>>a;
}while(a=='y');
}
0 Response to "Membuat Program Dengan While Do dan Switch Case "
Post a Comment