19.10.11

C++ MENU & GOTO

#include <iostream.h>
#include <conio.h>
void main()
{
 char lg;
 int pil;
 float hk,ht,hs,tot1,tot2,tot3,totpem;
 clrscr();
 awal :
 cout <<" MENU \n\n";
 cout <<" 1.kopi \n\n";
 cout <<" 2.teh \n\n";
 cout <<" 3.susu \n\n";
 cout <<" Masukkan Pilihan Anda    : ";
 cin >>pil;
 cout <<"\n";
 switch (pil)
 {
    case 1 :
        cout <<" =================================== \n";
        cout <<" ** Kopi ** " << endl;
        cout <<" Harga             : Rp 3.000,- \n";


        cout <<" Jumlah Pembelian     : "; cin >>hk;
        tot1=3000*hk;
        cout <<" Pembayaran         : " <<tot1 << endl;
        break;
    case 2 :
        cout <<" =================================== \n";
        cout <<" ** Teh ** " << endl;
        cout <<" Harga             : Rp 2.000,- \n";
        cout <<" Jumlah Pembelian     : "; cin >>ht;
        tot2=2000*ht;
        cout <<" Pembayaran         : " <<tot2 << endl;
        break;
    case 3 :
        cout <<" =================================== \n";
        cout <<" ** Susu ** " << endl;
        cout <<" Harga             : Rp 2.500,- \n";
        cout <<" Jumlah Pembelian     : "; cin >>hs;
        tot3=2500*hs;
        cout <<" Pembayaran         : " <<tot3 << endl;
        break;
    default :
    cout <<"Pilihan salah...!";
 }
    cout <<"\n\n";
    cout <<" Apakah Anda Mau Memesan Lagi ? [y/t] "; cin >>lg;
    if (lg=='y')
        {
        goto awal;
        }
    else if (lg=='t')
        {
        totpem=(tot1)+(tot2)+(tot3);
        cout <<" total pembayaran     : " <<totpem;
        cout <<"\n\n";
        }
getch();
}
Blog Advertising

0 komentar:

Posting Komentar