Bangun datar dan bangun ruang
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Bangun datar dan bangun ruang

on

  • 754 views

Ini listing Bangun datar dan bangun ruang buat algoritma pemograman, Dev-C++

Ini listing Bangun datar dan bangun ruang buat algoritma pemograman, Dev-C++

Statistics

Views

Total Views
754
Views on SlideShare
754
Embed Views
0

Actions

Likes
0
Downloads
18
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Bangun datar dan bangun ruang Document Transcript

  • 1. #include<iostream> #include <cstdlib> using namespace std; int main() {system("color a"); menu: int bangun,bangundatar,bangunruang; char ulang; cout<<"========================================================n "; cout<<"tMENGHITUNG BANGUN DATAR DAN BANGUN RUANGn"; cout<<"========================================================n "; cout<<"1. Bangun Datarn"; cout<<"2. Bangun Ruangn"; cout<<"Pilih bangun yang akan dihitung: ";cin>>bangun; switch(bangun) { case 1://BANGUN DATAR int klp,kll,kls,klla; cout<<"========================================================n "; cout<<"1. Persegin"; cout<<"2. Lingkarann";
  • 2. cout<<"3. Segitigan"; cout<<"4. Layang-layangn"; cout<<"Pilih bangun yang akan dihitung: ";cin>>bangundatar; switch(bangundatar) { case 1://PERSEGI float sp,kp,lp; cout<<"========================================================n "; cout<<"1. Kelilingn"; cout<<"2. Luasn"; cout<<"Pilih yang akan dihitung: ";cin>>klp; switch(klp) { case 1: cout<<"========================================================n "; cout<<"Keliling Persegin"; cout<<"========================================================n "; cout<<"Masukkan sisi= ";cin>>sp; kp=4*sp; cout<<"Maka keliling persegi= "<<kp; break; case 2:
  • 3. cout<<"========================================================n "; cout<<"Luas persegin"; cout<<"========================================================n "; cout<<"Masukkan sisi= ";cin>>lp; lp=sp*sp; cout<<"Maka luas persegi= "<<lp; } break; case 2://LINGKARAN float dl,rl,kl,ll; cout<<"========================================================n "; cout<<"1. Kelilingn"; cout<<"2. Luasn"; cout<<"Pilih yang akan dihitung: ";cin>>klp; switch(kll) { case 1: cout<<"========================================================n "; cout<<"Keliling lingkarann";
  • 4. cout<<"========================================================n "; cout<<"Masukkan diameter= ";cin>>dl; kl=3.14*dl; cout<<"Maka keliling lingkaran= "<<kl; break; case 2: cout<<"========================================================n "; cout<<"Luas lingkarann"; cout<<"========================================================n "; cout<<"Masukkan jari-jari= ";cin>>rl; ll=3.13*rl*rl; cout<<"Maka luas lingkaran= "<<ll; } break; case 3://SEGITIGA float s1,s2,s3,as,ts,ks,ls; cout<<"========================================================n "; cout<<"1. Kelilingn"; cout<<"2. Luasn"; cout<<"Pilih yang akan dihitung: ";cin>>klp; switch(klp)
  • 5. { case 1: cout<<"========================================================n "; cout<<"Keliling segitigan"; cout<<"========================================================n "; cout<<"Masukkan sisi 1= ";cin>>s1; cout<<"Masukkan sisi 2= ";cin>>s2; cout<<"Masukkan sisi 3= ";cin>>s3; ks=s1+s2+s3; cout<<"Maka keliling segitiga= "<<ks; break; case 2: cout<<"========================================================n "; cout<<"Luas segitigan"; cout<<"========================================================n "; cout<<"Masukkan alas= ";cin>>as; cout<<"Masukkan tinggi= ";cin>>ts; ls=0.5*as*ts; cout<<"Maka luas segitiga= "<<ls; }
  • 6. break; case 4://LAYANG-LAYANG float d1,d2,si1,si2,kla,lla; cout<<"========================================================n "; cout<<"1. Kelilingn"; cout<<"2. Luasn"; cout<<"Pilih yang akan dihitung: ";cin>>klla; switch(klla) { case 1: cout<<"========================================================n "; cout<<"Keliling Layang-layangn"; cout<<"========================================================n "; cout<<"Masukkan sisi 1= ";cin>>si1; cout<<"Masukkan sisi 2= ";cin>>si2; kla=(2*si1)+(2*si2); cout<<"Maka keliling persegi= "<<kp; break; case 2: cout<<"========================================================n "; cout<<"Luas Layang-layangn";
  • 7. cout<<"========================================================n "; cout<<"Masukkan diagonal 1= ";cin>>d1; cout<<"Masukkan diagonal 2= ";cin>>d2; lla=0.5*d1*d2; cout<<"Maka luas Layang-layang= "<<lla; } } break; case 2://BANGUN RUANG int lvk,lvba,lvt,lvbo; cout<<"========================================================n "; cout<<"1. Kubusn"; cout<<"2. Balokn"; cout<<"3. Tabungn"; cout<<"4. Bolan"; cout<<"Pilih bangun yang akan dihitung: ";cin>>bangunruang; switch(bangunruang) { case 1://KUBUS float rk,lpk,vk; cout<<"========================================================n ";
  • 8. cout<<"1. Luas permukaann"; cout<<"2. Volumen"; cout<<"Pilih yang akan dihitung: ";cin>>lvk; switch(lvk) { case 1: cout<<"========================================================n "; cout<<"Luas Permukaan Kubusn"; cout<<"========================================================n "; cout<<"Masukkan rusuk= ";cin>>rk; lpk=6*rk*rk; cout<<"Maka luas permukaan kubus= "<<lpk; break; case 2: cout<<"========================================================n "; cout<<"Volume Kubusn"; cout<<"========================================================n "; cout<<"Masukkan rusuk= ";cin>>rk; vk=rk*rk*rk; cout<<"Maka volume kubus= "<<vk;
  • 9. } break; case 2://BALOK float pba,lba,tba,lpba,vba; cout<<"========================================================n "; cout<<"1. Luas Permukaann"; cout<<"2. Volumen"; cout<<"Pilih yang akan dihitung: ";cin>>lvba; switch(lvba) { case 1: cout<<"========================================================n "; cout<<"Luas Permukaan Balokn"; cout<<"========================================================n "; cout<<"Masukkan panjang balok= ";cin>>pba; cout<<"Masukkan lebar balok= ";cin>>lba; cout<<"Masukkan tinggi balok= ";cin>>tba; lpba=2*(pba*lba)+(pba*tba)+(lba*tba); cout<<"Maka "<<lpba; break; luas permukaan balok=
  • 10. case 2: cout<<"========================================================n "; cout<<"Volume Balokn"; cout<<"========================================================n "; cout<<"Masukkan panjang balok= ";cin>>pba; cout<<"Masukkan lebar balok= ";cin>>lba; cout<<"Masukkan tinggi balok= ";cin>>tba; vba=pba*lba*tba; cout<<"Maka volume balok= "<<vba; } break; case 3://TABUNG float rt,tt,lpt,vt; cout<<"========================================================n "; cout<<"1. Luas Permukaann"; cout<<"2. Volumen"; cout<<"Pilih yang akan dihitung: ";cin>>lvt; switch(lvt) { case 1:
  • 11. cout<<"========================================================n "; cout<<"Luas Permukaan Tabungn"; cout<<"========================================================n "; cout<<"Masukkan jari-jari tabung= ";cin>>rt; cout<<"Masukkan tinggi tabung= ";cin>>tt; lpt=2*3.14*rt*(rt+tt); cout<<"Maka luas permukaan tabung= "<<lpt; break; case 2: cout<<"========================================================n "; cout<<"Volume Tabungn"; cout<<"========================================================n "; cout<<"Masukkan jari-jari tabung= ";cin>>rt; cout<<"Masukkan tinggi tabung= ";cin>>tt; vt=3.14*rt*rt*tt; cout<<"Maka volume tabung= "<<vt; } break; case 4://BOLA
  • 12. float rbo,lpbo,vbo; cout<<"========================================================n "; cout<<"1. Luas Permukaann"; cout<<"2. Volumen"; cout<<"Pilih yang akan dihitung: ";cin>>lvbo; switch(lvbo) { case 1: cout<<"========================================================n "; cout<<"Luas Permukaan Bolan"; cout<<"========================================================n "; cout<<"Masukkan jari-jari= ";cin>>rbo; lpbo=4*3.14*rbo*rbo; cout<<"Maka luas permukaan bola= "<<lpbo; break; case 2: cout<<"========================================================n "; cout<<"Volume Bolan"; cout<<"========================================================n ";
  • 13. cout<<"Masukkan jari-jari bola= ";cin>>rbo; vbo=1.33*3.14*rbo*rbo; cout<<"Maka volume bola= "<<vbo; } } } cout<<"n---------------------------------------------------------n"; cout<<"Apakah Anda ingin mengulang?(Y/T)";cin>>ulang; cout<<endl; switch(ulang) { case 'Y': goto menu; break; case 'y': goto menu; break; case 'T': break; case 't': break; default: cout<<"Masukkan salahn"; cout<<"Apakah Anda ingin mengulang?(Y/T)";cin>>ulang;
  • 14. cout<<endl; goto menu; } }