Advertisement
JonathanA007

Jonathan Arya Priguna/Tugas 5 Soal 2

Oct 5th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int a,b,r,k,l,x,y,z,pil;
  6.     cout<< "menghitung luas dan keliling persegi panjang : ";
  7.     cout<< "menghitung luas dan keliling lingkaran : ";
  8.     cout<< "menghitung luas dan keliling seigitiga : ";
  9.     cout<<"Pilih menu(1/2/3)";
  10.     cin >> pil;
  11.  
  12.     cout<< "Masukkan a : ";
  13.     cin>> a;
  14.     cout<< "Masukkan b : ";
  15.     cin>> b;
  16.     cout<< "Masukkan r : ";
  17.     cin>> r;
  18.  
  19.     switch (pil){
  20.         case 1:
  21.              k=2*a+2*b;
  22.              l=a*b;
  23.              cout<< "keliling persegi panjang : "<< k <<" cm" <<endl;
  24.              cout<< "luas persegi panjang : "<< l <<" cm2" <<endl;
  25.             break;
  26.         case 2:
  27.         k=2*3.14*r;
  28.         l=3.14*r*r;
  29.         cout<< "keliling lingkaran : "<< k <<"cm"<<endl;
  30.         cout<< "luas lingkaran : "<< l <<"cm2"<<endl;
  31.         break;
  32.         case 3:
  33.         k=a+b+r;
  34.         l=0.5*a*b;
  35.         cout<< "keliling segitiga : "<< k <<"cm"<<endl;
  36.         cout<< "luas segitiga : "<< l <<"cm2"<<endl;
  37.         break;
  38.  
  39.  
  40.     default:
  41.         cout<<"Data tidak ditemukan, silakan menginput data yang benar"<<endl;
  42.         break;
  43. }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement