Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main(){
- int a,b,r,k,l,x,y,z,pil;
- cout<< "menghitung luas dan keliling persegi panjang : ";
- cout<< "menghitung luas dan keliling lingkaran : ";
- cout<< "menghitung luas dan keliling seigitiga : ";
- cout<<"Pilih menu(1/2/3)";
- cin >> pil;
- cout<< "Masukkan a : ";
- cin>> a;
- cout<< "Masukkan b : ";
- cin>> b;
- cout<< "Masukkan r : ";
- cin>> r;
- switch (pil){
- case 1:
- k=2*a+2*b;
- l=a*b;
- cout<< "keliling persegi panjang : "<< k <<" cm" <<endl;
- cout<< "luas persegi panjang : "<< l <<" cm2" <<endl;
- break;
- case 2:
- k=2*3.14*r;
- l=3.14*r*r;
- cout<< "keliling lingkaran : "<< k <<"cm"<<endl;
- cout<< "luas lingkaran : "<< l <<"cm2"<<endl;
- break;
- case 3:
- k=a+b+r;
- l=0.5*a*b;
- cout<< "keliling segitiga : "<< k <<"cm"<<endl;
- cout<< "luas segitiga : "<< l <<"cm2"<<endl;
- break;
- default:
- cout<<"Data tidak ditemukan, silakan menginput data yang benar"<<endl;
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement