Program menghitung luas dengan Dev c++
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char
*argv[])
{
system ("color f0"); // digunkaan untuk menganti tampilan warna
float bujursangkar, lingkaran, segitiga;
float trapesium, luas;
float sisi, jari, tinggi;
float alas, atas;
const float phi=3.14;
char jwb;
do
{
cout<<"/* =================================================
*/"<<endl;
cout<<"/* PROGRAM
*/"<<endl;
cout<<"/* PENGHITUNG LUAS */"<<endl;
cout<<"/* BUJURSANGKAR, LINGKARAN, SEGITIGA,
TRAPESIUM */"<<endl;
cout<<"/* ================================================
*/"<<endl;
cout<<endl<<endl;
cout<<"/* LUAS YANG INGIN ANDA
HITUNG */"<<endl;
cout<<endl<<endl;
cout<<" 1. Luas bujursangkar
"<<endl<<endl;
cout<<" 2. Luas lingkaran "<<endl<<endl;
cout<<" 3. Luas segitiga "<<endl<<endl;
cout<<" 4. Luas Trapesium "<<endl<<endl;
cout<<" Pilihlah Luas Yang ingin
anda hitung [ 1 - 4 ] "
;cin>>luas;
cout<<endl<<endl;
if (luas==1)
{
cout<<"/* ================================================
*/"<<endl;
cout<<" Luas Bujursangkar "<<endl;
cout<<"/* ================================================
*/"<<endl;
cout<<endl;
cout<<" MASUKKAN SISI SISINYA =
";cin>>sisi;
bujursangkar = sisi*sisi;
cout<<endl;
cout<<" Luas Bujur sangkar
"<<bujursangkar<<" m2 "<<endl;
cout<<endl;
}
else if (luas==2)
{
cout<<"/* ================================================
*/"<<endl;
cout<<" Luas Lingkaran "<<endl;
cout<<"/* ================================================
*/"<<endl;
cout<<endl;
cout<<" MASUKKAN JARI - JARI =
";cin>>jari;
lingkaran = phi*jari*jari;
cout<<endl;
cout<<" Luas Lingkaran = "<<lingkaran<<" m2
"<<endl;
cout<<endl;
}
else if (luas==3)
{
cout<<"/* ================================================
*/"<<endl;
cout<<" Luas segitiga "<<endl;
cout<<"/* ================================================
*/"<<endl;
cout<<endl;
cout<<" MASUKKAN ALAS = ";cin>>alas;
cout<<endl;
cout<<" MASUKKAN TINGGI =
";cin>>tinggi;
segitiga = 0.5*alas*tinggi;
cout<<endl;
cout<<" Luas Segitiga adalah
"<<lingkaran<<" m2 "<<endl;
cout<<endl;
}
else if (luas==4)
{
cout<<"/* ================================================
*/"<<endl;
cout<<" Luas trapesium "<<endl;
cout<<"/* ================================================
*/"<<endl;
cout<<endl;
cout<<" MASUKKAN ALAS = ";cin>>alas;
cout<<endl;
cout<<" MASUKKAN ATAS = ";cin>>atas;
cout<<endl;
cout<<" MASUKKAN TINGGI =
";cin>>tinggi;
trapesium = ((alas + atas)*tinggi)/2;
cout<<endl;
cout<<" Luas Trapesium adalah
"<<trapesium<<" m2 "<<endl;
cout<<endl;
}
cout<<""<<endl;
cout<<" TERIMAKASIH ANDA TELAH MENGGUNAKAN
"<<endl;
cout<<" PROGRAM KAMI "<<endl;
cout<<""<<endl;
cout<<" Kembali ke program
penghitung luas [ Y/T] ";
cin>> jwb;
}
while (jwb=='Y' || jwb=='y');
//system("PAUSE");
return EXIT_SUCCESS;
}
Gambar hasil program penghitung luas :
makasih gan... ijin copast buat tugas nih, :D
BalasHapusthanks gan
BalasHapus