Fungsi Operator Menggunakan CASE


#include <iostream.h>
#include <conio.h>
void main()
{
cout<<"MENU ::"<<endl;
cout<<"==========================="<<endl;
cout<<"1.MENGHITUNG LUAS SEGITIGA"<<endl;
cout<<"2.MENGHITUNG LUAS LINGKARAN"<<endl;
cout<<"3.MENGHITUNG LUAS PERSEGI"<<endl;
cout<<"==========================="<<endl;
int MENU;
cout<<"MASUKKAN NOMOR MENU : ";
cin >> MENU;
        cout<<"==========================="<<endl;
switch (MENU)
{
case 1 : int A,T,L ;
cout<<"MENU MENGHITUNG LUAS SEGITIGA\n";
cout<<"========================\n";
cout<< "Masukkan Alas = "; cin>>A ;
cout<<"Masukkan Tinggi = "; cin>>T;
L=A*T*0.5;
cout<<"Luas Segitiga = "<<L;
cout<<"\n========================";
break;
case 2 : cout <<"MENU MENGHITUNG LUAS LINGKARAN\n";
float JARI,LUAS;
cout<<"========================\n";
cout<<"Masukkan Jari Lingkaran = "; cin>>JARI;
LUAS=JARI*JARI*3.14;
cout<<"LUAS LINGKARAN = " <<LUAS;
cout<<"\n========================";
case 3 : int PJ,LB,LS ;
cout<<"MENU MENGHITUNG LUAS PERSEGI\n";
cout<<"========================\n";
cout<< "Masukkan Panjang = "; cin>>PJ ;
cout<<"Masukkan Lebar = "; cin>>LB;
LS=PJ*LB;
cout<<"Luas Segitiga = "<<LS ";
cout<<"\n========================";
break;

default:cout<<"Ma'af menu yang anda pilih belum kami sediakan"<<endl;
break;
}
}

0 komentar:

Posting Komentar

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Lady Gaga, Salman Khan