Membuat Program Menu menggunakan Borland C++

Membuat Program Menu
menggunakan Borland C++

1.       Buka aplikasi Borland C++ pada PC/Laptop anda.
2.       Klik File, New, Project
3.       Untuk codingnya adalah sebagai berikut :
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
main()
{
clrscr();
int pil;
system("color 3D");
cout<<"--------Menu--------\n";
cout<<"1.Game Tic Tac Toe \n";
cout<<"2.Piramida Angka \n";
cout<<"3.Exit \n";
cout<<"--------------------\n";
cout<<"Masukkan Pilihan Anda[1..3]:";cin>>pil;
switch(pil)
{
case 1:
clrscr();
//isi program pertama (Piramida Angka)//
clrscr();
int z, baris, kolom;
char a, b, c, d, e, f, g, h, i, ulang;
cout << "\t"  << "===========" << endl;
cout << "\t""TIC TAC TOE" << endl;
cout << "\t"  << "===========" << endl;
cout << "\n\n""Apakah Anda Ingin Bermain?\nPlay [p]\nExit [e]\n";
cin >> ulang;
if(ulang=='p')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
cout << "\t" "TIC TAC TOE" << endl << endl;
mulai:
a = ' ';
b = ' ';
c = ' ';
d = ' ';
e = ' ';
f = ' ';
g = ' ';
h = ' ';
i = ' ';
z=1;
while(z<=10)
{
clrscr();
lanjut:
cout <<"\tGAME TIC TAC TOE" << endl << endl;
cout << "\t"  << " =============" << endl;
cout << "\t" << " | " << a << " | " << b
<< " | " << c << " | " << endl;
cout << "\t"  << " =============" << endl;
cout << "\t" << " | " << d << " | " << e <<
" | " << f << " | " << endl;
cout << "\t"  << " =============" << endl;
cout << "\t" << " | " << g << " | " << h
<< " | " << i << " | " << endl;
cout << "\t"  << " =============" << endl << endl;
if(z==10)
{
clrscr();
cout <<"\tGAME TIC TAC TOE" << endl << endl;
cout << "\t"  << " =============" << endl;
cout << "\t" << " | " << a << " | " << b
<< " | " << c << " | " << endl;
cout << "\t"  << " =============" <<
cout << "\t" << " | " << d << " | " << e
<< " | " << f << " | " << endl;
cout << "\t"  << " =============" <<
cout << "\t" << " | " << g << " | " << h
<< " | " << i << " | " << endl;
cout << "\t"  << " =============" << endl << endl;
cout << "Draw" << endl << endl;
cout << "Apakah Anda Ingin Main Lagi [y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
if(((a=='X')&&(b=='X'))&&(c=='X'))
{
cout << "Player 1 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi [y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((d=='X')&&(e=='X'))&&
(f=='X'))
{
cout << "Player 1 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((g=='X')&&(h=='X'))&&
(i=='X'))
{
cout << "Player 1 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((a=='X')&&(d=='X'))&&
(g=='X'))
{
cout << "Player 1 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((b=='X')&&(e=='X'))&&
(h=='X'))
{
cout << "Player 1 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((c=='X')&&(f=='X'))&&(i=='X'))
{
cout << "Player 1 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((a=='X')&&(e=='X'))&&
(i=='X'))
{
cout << "Player 1 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((c=='X')&&(e=='X'))&&
(g=='X'))
{
cout << "Player 1 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((a=='O')&&(b=='O'))&&
(c=='O'))
{
cout << "Player 2 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((d=='O')&&(e=='O'))&&
(f=='O'))
{
cout << "Player 2 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((g=='O')&&(h=='O'))&&
(i=='O'))
{
cout << "Player 2 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((a=='O')&&(d=='O'))&&
(g=='O'))
{
cout << "Player 2 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((b=='O')&&(e=='O'))&&
(h=='O'))
{
cout << "Player 2 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((c=='O')&&(f=='O'))&&(i=='O'))
{
cout << "Player 2 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((a=='O')&&(e=='O'))&&
(i=='O'))
{
cout << "Player 2 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
else if(((c=='O')&&(e=='O'))&&
(g=='O'))
{
cout << "Player 2 Menang" << endl<< endl;
cout << "Apakah Anda Ingin Main Lagi[y/n] ? ";
cin >> ulang;
if(ulang=='y')
{
clrscr();
goto mulai;
}
else
{
return 0;
}
}
if(z % 2 == 1)
{
cout <<"Player 1 [X]";
}
else
{
cout <<"Player 2 [O]";
}
cout << endl << endl << "Masukan Baris [V] [1..3] : ";
cin >> baris;
if(baris>3)
{
cout << "Bilangan Diluar Jangkauan" << endl;
cout << "Masukan Angka 1 Sampai 3";
getch();
clrscr();
goto lanjut;
}
cout << "Masukan kolom [>] [1..3] : ";
cin >> kolom;
if(kolom>3)
{
cout << "Bilangan Diluar Jangkauan" << endl;
cout << "Masukan Angka 1 Sampai 3";
getch();
clrscr();
goto lanjut;
}
if((baris==1)&&(kolom==1))
{
if(a!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
a = 'X';
}
else
{
a = 'O';
}
}
}
else if((baris==1)&&(kolom==2))
{
if(b!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
b = 'X';
}
else
{
b = 'O';
}
}
}
else if((baris==1)&&(kolom==3))
{
if(c!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
c = 'X';
}
else
{
c = 'O';
}
}
}
else if((baris==2)&&(kolom==1))
{
if(d!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
d = 'X';
}
else
{
d = 'O';
}
}
}
else if((baris==2)&&(kolom==2))
{
if(e!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
e = 'X';
}
else
{
e = 'O';
}
}
}
else if((baris==2)&&(kolom==3))
{
if(f!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
f = 'X';
}
else
{
f = 'O';
}
}
}
else if((baris==3)&&(kolom==1))
{
if(g!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
g = 'X';
}
else
{
g = 'O';
}
}
}
else if((baris==3)&&(kolom==2))
{
if(h!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
h = 'X';
}
else
{
h = 'O';
}
}
}
else if((baris==3)&&(kolom==3))
{
if(i!=' ')
{
z--;
cout << endl << "Sudah Diisi";
getch();
}
else
{
if(z % 2 == 1)
{
i = 'X';
}
else
{
i = 'O';
}
}
}
z++;
clrscr();
goto lanjut;
}
getch();
goto mulai;
case 2:
clrscr();
//isi program kedua (Game Tic Tac toe)//
int jbaris, x, j, bil;
clrscr;
cout<<"\t""PIRAMIDA ANGKA";
cout<<"\n\t""--------------";
cout<<"\n""Input(Angka):";
cin>>jbaris;
cout<<"\n";for(x=1;x<=jbaris;x++)
{
for(j=1;j<=jbaris-x;j++)
cout<<" ";
for(bil=x;bil>=1;bil--)
{
printf("%d",bil);
}
for(bil=2;bil<=x;bil++)
{
printf("%d",bil);
}
cout<<"\n";
}
printf("\n\n\n\t"    "Created By:");
printf("\n\t""Fitri Febriani");
cout <<"\n\n\n""Apakah Anda Ingin Keluar [y/n] ? ";
cin >> ulang;
if(ulang=='n')
{
clrscr();
cout<<"--------Menu--------\n";
cout<<"1.Game Tic Tac Toe \n";
cout<<"2.Piramida Angka \n";
cout<<"3.Exit \n";
cout<<"--------------------\n";
cout<<"Masukkan Pilihan Anda[1..3]:";cin>>pil;
switch(pil)
goto mulai;
clrscr();
clrscr();
goto mulai;
}
else
{
return 0;
}
getch();
goto mulai;
case 3:
clrscr();
//isi program ketiga (Exit)//
clrscr();
cout<<"Apakah Anda Yakin Ingin Keluar [y/n] ? ";
cin >> ulang;
if(ulang=='n')
{
clrscr();
cout<<"--------Menu--------\n";
cout<<"1.Game Tic Tac Toe \n";
cout<<"2.Piramida Angka \n";
cout<<"3.Exit \n";
cout<<"--------------------\n";
cout<<"Masukkan Pilihan Anda[1..3]:";cin>>pil;
switch(pil)
goto mulai;
clrscr();
}
else
{
return 0;
}
getch();
goto mulai;
default:cout<<"\nSilahkan Masukkan Pilihan Yang Benar:";
getch();
goto mulai;
}
getch();
return 0;
}

4.       Selamat mencoba kawan.. semoga penjelasan diatas dapat bermanfaat dan mempermudah teman-teman semua dalam pembuatan program.
Tetap semangat, terus berusaha dan pantang menyerah !!  Selamat belajar..

http://fitrifebriani26.blogspot.com

Komentar

Postingan populer dari blog ini

Membuat Program Penginapan Hotel menggunakan Microsoft Visual Basic 2010 Express

Membuat Program Penjualan Barang menggunakan Microsoft Visual Basic 2010 Express

Membuat Program Data Hotel menggunakan Microsoft Visual Basic 2010 Express