Nih gan tugas ane scrib membuat program menebak tanggal lahir dengan bahasa pemrograman c++
LANGSUNG AJA
#include<conio.h>
#include<iostream.h>
void main()
{
int tekan1,kode,hasil,nilai1,nilai2,nilai3,nilai4,nilai5;
char tabel1,tabel2,tabel3,tabel4,tabel5,mengulang,keluar,ulangi;
clrscr();
ulang1:
cout<<" SELAMAT DATANG\n";
cout<<" INI ADALAH PROGRAM UNTUK MENEBAK TANGGAL LAHIR ANDA\n";
cout<<"\n";
cout<<" TEKAN 1 UNTUK KE MENU UTAMA\n";
cout<<" "; cin>>tekan1;
ulang2:
clrscr();
if(tekan1==1)
{
cout<<"===========================MENU===============================\n";
cout<<"= =\n";
cout<<"=======================1.Start Game===========================\n";
cout<<"=======================2.About================================\n";
cout<<"=======================3.Exit=================================\n";
cout<<"MASUKKAN KODE MENU (1,2,3)\n";
cin>>kode;
ulang3:
clrscr();
}
if(kode==1)
{
cout<<"ANDA MEMULAI PERMAINAN\n";
cout<<"SILAHKAN AMATI TABEL DI BAWAH INI\n";
cout<<"DARI TABEL DI BAWAH INI,TABEL NOMER BERAPA SAJA YANG ADA ANGKA TANGGAL LAHIR ANDA???\n";
cout<<"SILAHKAN MASUKKAN Y/N JIKA TABEL 1-5 TERDAPAT TANGGAL ANDA:\n";
cout<<"\n";
cout<<"\n";
cout<<"TABEL 1\n";
cout<<"================================\n";
cout<<"|| 1 | 3 | 5 | 7 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 9 | 11 | 13 | 15 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 17 | 19 | 21 | 23 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 25 | 27 | 29 | 31 ||\n";
cout<<"================================\n";
cout<<"\n";
cout<<"Apakah tabel ke 1 terdapat tanggal lahir anda?\n";
cout<<"Tekan Y/N>>";
cin>>tabel1;
if(tabel1=='y'||tabel1=='Y')
{
nilai1=1;
}
else
{
nilai1=0;
}
cout<<"\n";
cout<<"TABEL 2\n";
cout<<"================================\n";
cout<<"|| 2 | 3 | 6 | 7 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 10 | 11 | 14 | 15 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 18 | 19 | 22 | 23 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 26 | 27 | 30 | 31 ||\n";
cout<<"================================\n";
cout<<"\n";
cout<<"\n";
cout<<"Apakah tabel ke 2 terdapat tanggal lahir anda?\n";
cout<<"Tekan Y/N>>";
cin>>tabel2;
if(tabel2=='y'||tabel2=='Y')
{
nilai2=2;
}
else
{
nilai2=0;
}
cout<<"TABEL 3\n";
cout<<"================================\n";
cout<<"|| 4 | 5 | 6 | 7 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 12 | 13 | 14 | 15 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 20 | 21 | 22 | 23 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 28 | 29 | 30 | 31 ||\n";
cout<<"================================\n";
cout<<"\n";
cout<<"Apakah tabel ke 3 terdapat tanggal lahir anda?\n";
cout<<"Tekan Y/N>>";
cin>>tabel3;
if(tabel3=='y'||tabel3=='Y')
{
nilai3=4;
}
else
{
nilai3=0;
}
cout<<"\n";
cout<<"TABEL 4\n";
cout<<"================================\n";
cout<<"|| 8 | 9 | 10 | 11 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 12 | 13 | 14 | 15 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 24 | 25 | 26 | 27 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 28 | 29 | 30 | 31 ||\n";
cout<<"================================\n";
cout<<"\n";
cout<<"Apakah tabel ke 4 terdapat tanggal lahir anda?\n";
cout<<"Tekan Y/N>>";
cin>>tabel4;
if(tabel4=='y'||tabel4=='Y')
{
nilai4=8;
}
else
{
nilai4=0;
}
cout<<"\n";
cout<<"TABEL 5\n";
cout<<"================================\n";
cout<<"|| 16 | 17 | 18 | 19 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 20 | 21 | 22 | 23 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 24 | 25 | 26 | 27 ||\n";
cout<<"||-------+------+------+------||\n";
cout<<"|| 28 | 29 | 30 | 31 ||\n";
cout<<"================================\n";
cout<<"\n";
cout<<"\n";
cout<<"Apakah tabel ke 5 terdapat tanggal lahir anda?\n";
cout<<"Tekan Y/N>>";
cin>>tabel5;
if(tabel5=='y'||tabel5=='Y')
{
nilai5=16;
}
else
{
nilai5=0;
}
hasil=nilai1+nilai2+nilai3+nilai4+nilai5;
cout<<"\n";
cout<<"\n";
cout<<"TANGGAL LAHIR ANDA ADALAH="<<hasil<<endl;
cout<<"\n";
cout<<"\n";
cout<<"Apakah anda ingin mengulang ?\n";
cout<<"Tekan Y untuk mengulang,dan tekan N untuk kembali ke menu utama>>";
cin>>mengulang;
if(mengulang=='y'||mengulang=='Y')
{
goto ulang3;
}
else if(mengulang=='n'||mengulang=='N')
{
goto ulang2;
}
else
{
cout<<"MAAF KODE YANG ANDA MASUKKAN SALAH!!!\n";
cout<<"Tekan Y untuk mengulang=";
cin>>ulangi;
}
if(ulangi=='y'||ulangi=='Y')
{
goto ulang2;
}
else
{
cout<<"GAME OVER\n";
}
}
else if(kode==2)
{
cout<<"Ini adalah permainan tebak tanggal lahir.\n";
cout<<"Program ini kami buat untuk memenuhi tugas\n";
cout<<"akhir semester 1 algoritma pemrograman\n";
cout<<"Tim pembuat\n";
cout<<"1.Rizky Tama(4111084) \n";
cout<<"2.M.Agung.R (4111067)\n";
cout<<"3.M.Maghfur(4111072)\n";
cout<<"3.Khoirul Abdilah(41110)\n";
cout<<("Tekan Y untuk kembali ke menu utama>>");
cin>>mengulang;
if(mengulang=='y'||mengulang=='Y')
{
goto ulang2;
}
else
{
cout<<"MAAF KODE YANG ANDA MASUKKAN SALAH!!!\n";
cout<<"Tekan Y untuk mengulang=";
cin>>ulangi;
}
if(ulangi=='y'||ulangi=='Y')
{
goto ulang2;
}
else
{
cout<<"GAME OVER\n";
}
}
else if(kode==3)
{
cout<<"Apakah anda yakin ingin keluar dari permainan?\n";
cout<<"Tekan Y untuk Keluar tekan N untuk kembali ke menu utama\n";
cin>>keluar;
if(keluar=='y'||keluar=='Y')
{
clrscr();
cout<<"TERIMAKASIH TELAH MEMAINKAN PERMAINAN INI\n";
}
else if(keluar=='n'||keluar=='N')
{
goto ulang2;
}
else
{
cout<<"MAAF KODE YANG ANDA MASUKKAN SALAH!!!\n";
cout<<"Tekan Y untuk mengulang=";
cin>>ulangi;
}
if(ulangi=='y'||ulangi=='Y')
{
goto ulang2;
}
else
{
cout<<"GAME OVER\n";
}
}
else
{
cout<<"MAAF KODE YANG ANDA MASUKKAN SALAH!!!\n";
cout<<"Tekan Y untuk mengulang=";
cin>>ulangi;
}
if(ulangi=='y'||ulangi=='Y')
{
goto ulang1;
}
else
{
cout<<"GAME OVER\n";
}
}
SEKIAN GAN SEMOGA BERMANFAAT
TTC
1 JANGAN LUPA KASIH KOMENTAR YA:
mas itu prinsipnya gmna??
Posting Komentar