readbud - get paid to read and rate articles

Tugas UTS S3 Pemrograman 1

/*
Program UTS Praktikum Pemrograman I
Nama File : UTS.c
Nama : Wanda
*/

#include
#include
#include
#include

#define pass 1234
#define i 24

using namespace std;

int main(int argc, char *argv[])
{

//warna Latar
textbackground(GREEN);
system("cls");

//deklarasi
int x,password;//password
int pil;//menu
int y,ayam;//kasus anak ayam
int a,b,jml_genap;//Jumlah genap
int baris,kolom,jml,bil;

//inisialisasi
x=1;//password

//proses
do
{
gotoxy(19,11);textcolor(YELLOW);
cout<<"Masukkan password (kesempatan ke-"<>password;
if(password==pass)
{
gotoxy(19,12);cout<<"Password anda benar! Selamat Datang!"< gotoxy(19,13);cout<<"Tekan Enter!"< getch();
system("cls");
do
{
//inisialisasi
jml_genap=0;//jumlah genap dan ganjil
bil=1;//bilangan segitiga

textcolor(LIGHTGREEN);
gotoxy(i,7);cout<<" ================================ ";
textcolor(YELLOW);
gotoxy(i,8);cout<<"| Menu |";
textcolor(LIGHTGREEN);
gotoxy(i,9);cout<<" ================================ ";
textcolor(YELLOW);
gotoxy(i,10);cout<<"| 1. Kasus anak ayam |";
gotoxy(i,11);cout<<"| 2. Jumlah bilangan genap |";
gotoxy(i,12);cout<<"| 3. Tampilan angka segitiga |";
gotoxy(i,13);cout<<"| 4. Keluar |";
textcolor(LIGHTGREEN);
gotoxy(i,14);cout<<" ================================ ";
textcolor(YELLOW);
gotoxy(i,15);cout<<"| Masukkan pilihan [1..4] : |";
textcolor(LIGHTGREEN);
gotoxy(i,16);cout<<" ================================ ";
textcolor(LIGHTCYAN);
gotoxy(52,15);cin>>pil;
system("cls");
textcolor(YELLOW);
if(pil==1)
{
cout<<"Masukkan jumlah anak ayam: ";cin>>ayam;
cout< textcolor(LIGHTCYAN);
for(y=ayam;y>=2;y--)
{
cout<<"Anak ayam turun "< }
cout<<"Anak ayam turun 1, mati satu tinggal induknya"< }
else
if(pil==2)
{
cout<<"Masukkan batas bilangan : ";cin>>b;
textcolor(LIGHTCYAN);
cout<<"\nJumlah bilangan genap = ";
for(a=1;a<=b;a++)
{
if(a%2==0)
{
cout< jml_genap=jml_genap+a;
if(a cout<<" + ";
}
}
cout< cout<<" = "< }
else
if(pil==3)
{
cout<<"Masukkan banyak baris : ";cin>>jml;
cout< textcolor(LIGHTCYAN);
for(baris=1;baris<=jml;baris++)
{
for(kolom=1;kolom<=baris;kolom++)
{
cout< bil++;
}
cout< }
for(baris=jml-1;baris>=1;baris--)
{
for(kolom=1;kolom<=baris;kolom++)
{
cout< bil++;
}
cout< }
cout< }
else
if(pil==4)
{
textcolor(LIGHTCYAN);
cout<<"Terima kasih sudah menggunakan program ini!"< }
else
{
textcolor(LIGHTCYAN);
cout<<"Anda salah pilih!"< }
textcolor(WHITE);
system("PAUSE");
system("cls");
}while(pil!=4);
}
else
{
gotoxy(19,12);cout<<"Password anda salah! Coba lagi!"< gotoxy(19,13);cout<<"Tekan Enter!"< getch();
system("cls");
}
x++;
}while((password!=pass)&&(x!=4));

return EXIT_SUCCESS;
}

Tidak ada komentar:

Posting Komentar