# include <conio.h>
# include <iostream.h>
# include <stdio.h>
main()
{
int pil,s,p,l,a,t,LP,LPP;
float LS;
char ulang;
clrscr();
do{
cout <<"\n******************************";
cout <<"\n* PROGRAM PERHITUNGAN LUAS *";
cout <<"\n******************************";
cout <<"\n";
cout <<"\n1.Luas Persegi";
cout <<"\n2.Luas Persegi Panjang";
cout <<"\n3.Luas Segitiga";
cout <<"\n4.Exit";
cout <<"\n";
cout <<"\nMasukkan pilihan Anda ! : "; cin >>pil;
switch(pil){
case 1:
clrscr();
cout <<"\n==============================";
cout <<"\n= Perhitungan Luas Persegi =";
cout <<"\n==============================";
cout <<"\n";
cout <<"\nMasukkan sisi ! = "; cin >>s;
LP=s*s;
cout <<"\nLuas Persegi = " <<LP;
cout <<"\n\n\n";
break; /*break, berfungsi untuk keluar dari struktur switch*/
case 2:
clrscr();
cout <<"\n======================================";
cout <<"\n= Perhitungan Luas Persegi Panjang =";
cout <<"\n======================================";
cout <<"\n";
cout <<"\nMasukkan panjang ! = "; cin >>p;
cout <<"\nMasukkan lebar ! = "; cin >>l;
LPP=p*l;
cout <<"\nLuas Persegi Panjang = " <<LPP;
cout <<"\n\n\n";
break;
case 3:
clrscr();
cout <<"\n===============================";
cout <<"\n= Perhitungan Luas Segitiga =";
cout <<"\n===============================";
cout <<"\n";
cout <<"\nMasukkan alas ! = "; cin >>a;
cout <<"Masukkan tinggi ! = "; cin >>t;
LS=0.5*a*t;
cout <<"\nLuas Segitiga = " <<LS;
cout <<"\n\n\n";
break;
case 4:
clrscr();
break;
}
cout <<"Apakah Anda ingin mengulang ? [Y/T] : ";
cin >>ulang;
}
while(ulang=='Y'||ulang=='y');
cout <<"\2\2\2 TERIMA KASIH \2\2\2";
getch();
}
0 comments:
Post a Comment