Program Menu pada c++

Berikut adalah contoh program Menu dengan menggunakan bahasa pemrograman c++ :

#include <iostream.h>
#include <conio.h>
int pil;
int mie, es, bayar, jml_mie, jml_es, uangku, uangnya, selisih;
void main()
{
menu:
clrscr();
cout<<” Program Menu “<<endl;
cout<<” 1 Input 1 (Mie Ayam)”<<endl;
cout<<” 2 Input 2 “<<endl;
cout<<” 3 Kondisi “<<endl;
cout<<” 4 Exit “<<endl;
cout<<” Pilihan anda ” ;cin>>pil;
switch (pil) {
case 1 : goto input1 ;
case 2 : goto input2 ;
case 3 : goto kondisi ;
case 4 : goto exit ;
default: cout<<” Pilihan hanya 4 ” ;
input1 : {
clrscr();
gotoxy(15,1);cout<<“========== Mie Ayam Teh Cucun ==========\n”;
gotoxy(15,4);cout<<“Jumlah mie ayam = “; cin>>mie;
jml_mie = mie* 8000;
gotoxy(35,4);cout<<” x 8000 = RP “<<jml_mie<<“\n”;
gotoxy(15,5);cout<<“Jumlah es puter = “; cin>>es;
jml_es = es * 2500;
gotoxy(35,5);cout<<” x 2500 = RP “<<jml_es<<“\n”;
bayar = jml_mie + jml_es;
gotoxy(15,7);cout<<“========================================\n”;
gotoxy(15,9);cout<<“Jumlah bayar = “<<bayar;
getch();
goto menu;
}
input2 : {
clrscr();
cout<<“program 2 \n”;
cout<<“Hai “;
getch();
goto menu;
}
kondisi : {
clrscr();
gotoxy(18,1);cout<<“Kondisi \n”;
gotoxy(15,4);cout<<“Uang anda = “; cin>>uangku;
gotoxy(15,5);cout<<“Uang teman = “; cin>>uangnya;
if (uangku>uangnya)
{
selisih = uangku – uangnya;
gotoxy(15,7);cout<<“Uang anda lebih banyak “<<selisih;
gotoxy(44,7);cout<<“dari teman anda”;
}
else if (uangku<uangnya)
{
selisih = uangnya – uangku;
gotoxy(15,7);cout<<“Uang teman anda lebih banyak “<<selisih;
gotoxy(50,7);cout<<“dari uang anda”;
}
getch();
goto menu;
}
exit : {
clrscr();
cout<<“Thanks “;
getch();
}
}
}

^Rachmatika Irfani^

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 )

Gambar Twitter

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

Foto Facebook

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

Foto Google+

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

Connecting to %s