Source code:
#include <iostream> int main1() { cout<<"=============================================="<<endl; cout<<" Hitung Volume Bangun"<<endl; cout<<"=============================================="<<endl; cout<<"1.Volume Bola = 4/3 * 3.14 * r * r * r"<<endl; cout<<"2.Volume Tabung = 3.14 * r * r * t"<<endl; cout<<"3.Volume Limas = 1/3 * luas alas* t"<<endl; cout<<"4.Volume Prisma = luas alas * t"<<endl; cout<<"=============================================="<<endl; cout<<"5.Hitung Totatl Volume Bangun ruang . !!!"<<endl; cout<<"=============================================="<<endl; } float bola (float r) { float vb; vb=4*3.14*r*r*r/3; return (vb); } float tabung (float r,float t) { float vt; vt=3.14*r*r*t; return(vt); } float limas (float la,float t) { float vl; vl=1*la*t/3; return(vl); } float prisma (float lap,float t) { float vp; vp=lap*t; return(vp); } float total(float a,float b,float c,float d) { float jt; jt=a+b+c+d; return(jt); } main() { float tl1,tl2,tl3,tl4,jmlh; float z,x,r; int plh; main1(); cout<<endl<<"masukan pilihan = "; cin>>plh;cout<<endl; while(plh<=4){ switch(plh){ case 1 : cout<<"================================"<<endl<<endl; cout<<"1.Volume Bola"<<endl; cout<<"masukan jari-jari bola = ";cin>>r; tl1=bola(r); cout<<"volume bola = "<<tl1<<endl<<endl; cout<<"================================"<<endl; break; case 2 : cout<<"================================"<<endl<<endl; cout<<"2.Volume Tabung"<<endl; cout<<"masukan jari-jari tabung = ";cin>>z; cout<<"masukan tinggi tabung = ";cin>>x; tl2=tabung(z,x); cout<<"volume tabung = "<<tl2<<endl<<endl; cout<<"================================"<<endl; break; case 3 : cout<<"================================"<<endl<<endl; cout<<"3.Volume Limas"<<endl; cout<<"masukan luas alas limas = ";cin>>z; cout<<"masukan tinggi limas = ";cin>>x; tl3=limas(z,x); cout<<"volume limas = "<<tl3<<endl<<endl; cout<<"================================"<<endl; break; case 4 : cout<<"================================"<<endl<<endl; cout<<"4.Volume Prima"<<endl; cout<<"masukan luas alas prima = ";cin>>z; cout<<"masukan tinggi prisma = ";cin>>x; tl4=prisma(z,x); cout<<"volume prisma = "<<tl4<<endl<<endl; cout<<"================================"<<endl; break; case 5 : cout<<"==================================="<<endl; jmlh=total(tl1,tl2,tl3,tl4); cout<<endl<<"total volume-volume bangun = "<<jmlh<<endl<<endl; cout<<"==================================="<<endl<<endl; break; } cout<<endl<<"masukan pilihan = "; cin>>plh;cout<<endl; } if(plh==5){jmlh=total(tl1,tl2,tl3,tl4); cout<<"==================================="<<endl; cout<<endl<<"total volume-volume bangun = "<<jmlh<<endl<<endl;} cout<<"==================================="<<endl<<endl; getch(); }
Tidak ada komentar:
Posting Komentar