#include<iostream.h>
#include<conio.h>
// Kelompok :
// Khoirul As'Ari (120 103 119 )
// Imron Amrullah
// Supardi
// Ibnu Tantowi
// Setyawan Febri
class makhluk
{
public:
void berkembang();
};
class hewan :
public makhluk
{
public:
void bergerak();
};
class kuda :
public hewan
{
public:
void berlari();
};
main()
{
makhluk mk; hewan hw; kuda kd;
cout<<endl<<"Sifat-sifat dari Makhluk adalah :"<<endl;
mk.berkembang();
cout<<endl<<"Sifat-sifat dari Hewan adalah :"<<endl;
hw.berkembang(); hw.bergerak();
cout<<endl<<"Sifat-sifat dari Kuda adalah :"<<endl;
mk.berkembang(); hw.bergerak(); kd.berlari();
getch();
}
void makhluk::berkembang()
{
cout<<"Berkembang biak"<<endl;
}
void hewan::bergerak()
{
cout<<"Bergerak berpindah tempat"<<endl;
}
void kuda::berlari()
{
cout<<"Berlari"<<endl;
}
*
Senin, 09 Desember 2013
Senin, 21 Oktober 2013
Coding "PROGRAM APLIKASI FUNGSI MENGHITUNG LUAS"
#include <conio.h>
void lingkaran ()
{
float r, L;
cout<<"Masukkan jari-jari : ";
cin>>r;
cout<<endl;
L = 3.14 * r * r;
cout<<"Luasnya adalah : "<< L;
};
void segiempat ()
{
float s, L;
cout<<"Masukkan sisi : ";
cin>>s;
cout<<endl;
L= s * s;
cout<<"Luasnya adalah : "<< L;
};
void segitiga ()
{
float a, t, s, r, L;
cout<<"Masukkan alas : ";
cin>>a;
cout<<endl;
cout<<"Masukkan tinggi : ";
cin>>t;
cout<<endl;
L = 0.5 * a * t;
cout<<"Luasnya adalah : "<< L;
};
void persegi_panjang ()
{
float p,l, L;
cout<<"Masukkan panjang : ";
cin>>p;
cout<<endl;
cout<<"Masukkan lebar : ";
cin>>l;
cout<<endl;
L = p * l;
cout<<"Luasnya adalah : "<< L;
};
void main ()
{
float a, t, L;
int pil;
cout<<"==========================================="<<endl;
cout<<" PROGRAM APLIKASI FUNGSI MENGHITUNG LUAS "<<endl;
cout<<" KHOIRUL AS'ARI_ 120 103 119 "<<endl;
cout<<"==========================================="<<endl;
cout<<endl;
cout<<"1. Luas Lingkaran"<<endl;
cout<<"2. Luas Segiempat"<<endl;
cout<<"3. Luas Segitiga"<<endl;
cout<<"4. Luas Persegi_Panjang"<<endl;
cout<<endl;
cout<<"Ketik pilihan anda (1/2/3) : ";
cin>>pil;
cout<<endl<<endl;
if (pil==1){lingkaran ();}
else if (pil==2){segiempat ();}
else if (pil==3){segitiga ();}
else if (pil==4){persegi_panjang ();}
getch();
}
Senin, 30 September 2013
Coding PBO Perulangan Dengan menggunakan ( for, do while dan while )
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<"===============================================";
cout<<endl;
cout<<"PERRULANGAN BILANGAN DARI ANGKA DARI 1 SAMPAI 10";
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<endl;
cout<<"do_while_perulangan 1-10";
cout<<endl;
a=0;
do
{
a++;
cout<<","<<a;
}
while (a<10);
cout<<endl;
cout<<endl;
cout<<"do_while_perulangan bilangan genap";
cout<<endl;
a=0;
do
{
a+=2;
cout<<","<<a;
}
while (a<10);
cout<<endl;
cout<<endl;
cout<<"do_while_perulangan bilangan ganjil";
cout<<endl;
a=-1;
do
{
a+=2;
cout<<","<<a;
}
while (a<9);
cout<<endl;
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<endl;
cout<<"for_perulangan bilangan 1-10";
cout<<endl;
cout<<endl;
for (a=1;a<=10;a++)
{
cout<<","<<a;
}
cout<<endl;
cout<<endl;
cout<<"for_perulangan bilangan genap";
cout<<endl;
for (a=1;a<10;a++)
{
a+=1;
cout<<","<<a;
}
cout<<endl;
cout<<endl;
cout<<"for_perulangan bilangan ganjil";
cout<<endl;
for (a=-1;a<9;)
{
a+=2;
cout<<","<<a;
}
cout<<endl;
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<endl;
cout<<"while_perulangan bilangan 1-10";
cout<<endl;
cout<<endl;
a=1;
while(a<=10)
{
cout<<","<<a;
a++;
}
cout<<endl;
cout<<endl;
cout<<"while_perulangan bilangan genap";
cout<<endl;
a=2;
while(a<=10)
{
cout<<","<<a;
a+=2;
}
cout<<endl;
cout<<endl;
cout<<"while_perulangan bilangan ganjil";
cout<<endl;
a=1;
while(a<10)
{
cout<<","<<a;
a+=2;
}
getch();
}
#include<conio.h>
void main()
{
int a;
cout<<"===============================================";
cout<<endl;
cout<<"PERRULANGAN BILANGAN DARI ANGKA DARI 1 SAMPAI 10";
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<endl;
cout<<"do_while_perulangan 1-10";
cout<<endl;
a=0;
do
{
a++;
cout<<","<<a;
}
while (a<10);
cout<<endl;
cout<<endl;
cout<<"do_while_perulangan bilangan genap";
cout<<endl;
a=0;
do
{
a+=2;
cout<<","<<a;
}
while (a<10);
cout<<endl;
cout<<endl;
cout<<"do_while_perulangan bilangan ganjil";
cout<<endl;
a=-1;
do
{
a+=2;
cout<<","<<a;
}
while (a<9);
cout<<endl;
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<endl;
cout<<"for_perulangan bilangan 1-10";
cout<<endl;
cout<<endl;
for (a=1;a<=10;a++)
{
cout<<","<<a;
}
cout<<endl;
cout<<endl;
cout<<"for_perulangan bilangan genap";
cout<<endl;
for (a=1;a<10;a++)
{
a+=1;
cout<<","<<a;
}
cout<<endl;
cout<<endl;
cout<<"for_perulangan bilangan ganjil";
cout<<endl;
for (a=-1;a<9;)
{
a+=2;
cout<<","<<a;
}
cout<<endl;
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<"===============================================";
cout<<endl;
cout<<endl;
cout<<"while_perulangan bilangan 1-10";
cout<<endl;
cout<<endl;
a=1;
while(a<=10)
{
cout<<","<<a;
a++;
}
cout<<endl;
cout<<endl;
cout<<"while_perulangan bilangan genap";
cout<<endl;
a=2;
while(a<=10)
{
cout<<","<<a;
a+=2;
}
cout<<endl;
cout<<endl;
cout<<"while_perulangan bilangan ganjil";
cout<<endl;
a=1;
while(a<10)
{
cout<<","<<a;
a+=2;
}
getch();
}
Coding PBO_ Menghitung Tinggi badan dan Luas Lingkaran
#include <conio.h>
void main()
{ int kode; //tampilan utama
cout<<"|*****************************************|"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"| Nama : Khoirul As Ari |"<<endl;
cout<<"| Nim : 120103119 |"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"| PROGRAM PERHITUNGAN |"<<endl;
cout<<"|=========================================|"<<endl;
cout<<"| PILIHAN KODE |"<<endl;
cout<<"|=========================================|"<<endl;
cout<<"|1. Menghitung luas lingkaran |"<<endl;
cout<<"|2. Menghitung ukuran tinggi badan |"<<endl;
cout<<"|=========================================|"<<endl;
cout<<"MASUKKAN PILIHAN ANDA :";cin>>kode; //pemasukan kode
if (kode==1)
{
clrscr();
float j,luas; //penghitungan luas lingkaran
cout<<"|*****************************************|"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"| Nama : Khoirul As Ari |"<<endl;
cout<<"| Nim : 120103119 |"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"| MENGHITUNG LUAS LINGKARAN |"<<endl;
cout<<"|=========================================|"<<endl;
cout<<"MASUKKAN JARI-JARI :";cin>>j;
luas=3.14*j*j;
cout<<luas;
}
else if (kode==2)
{
clrscr();
int u; //penentuan ukuran badan
cout<<"|*****************************************|"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"| Nama : Khoirul As Ari |"<<endl;
cout<<"| Nim : 120103119 |"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"|*****************************************|"<<endl;
cout<<"| MENENTUKAN UKURAN BADAN ANDA |"<<endl;
cout<<"|=========================================|"<<endl;
cout<<"MASUKKAN UKURAN BADAN ANDA :";cin>>u;
if (u>=180)
{
cout<<"ANDA MEMILIKI UKURAN BADAN YANG TINGGI";
}
else if (u>=155&&u<=179)
{
cout<<"ANDA MEMILIKI UKURAN BADAN YANG SEDANG";
}
else if (u<155)
{
cout<<"ANDA MEMILIKI UKURAN BADAN YANG RENDAH";
}
}
else //jika kode yang dimasukkan salah
{
cout<<"\nMaaf kode yang anda masukkan salah..!!"<<endl<<endl;
}
getch();
}
Langganan:
Postingan (Atom)