//menghitung Luas dan volume kubus,balok,bola,limas,tabung pada c++
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
const float phi=3.14;
int main()
{
int iter=0, pil, a, b, c;
float volum, luas;
bool loop=true;
while(loop)
{
clrscr();
cout << "Selamat datang di program hitung"<< endl;
cout << "Anda berada pada iterasi ke-"<< iter << endl;
cout << endl;
cout << ">> Pilihan Menu: "<< endl;
cout << "1) Kubus "<< endl;
cout << "2) Balok"<< endl;
cout << "3) Bola"<< endl;
cout << "4) Limas segi empat"<< endl;
cout << "5) Tabung"<< endl;
cout << "0) Keluar dari program"<< endl;
cout << endl;
cout << "Silahkan masukkan angka pilihan anda: ";
cin >> pil;
switch(pil)
{
case 1:
cout << "Perhitungan Volume dan Luas Permukaan Kubus" << endl;
cout << "Panjang rusuk kubus = ";
cin >> a;
volum = a*a*a;
luas = a*a*6;
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 2:
cout << "Perhitungan Volume dan Luas Permukaan Balok" << endl;
cout << "Panjang balok = ";
cin >> a;
cout << "Lebar balok = ";
cin >> b;
cout << "Tinggi balok = ";
cin >> c;
volum = a*b*c;
luas = ((a * b) + (b * c) + (c * a)) * 2;
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 3:
cout << "Perhitungan Volume dan Luas Permukaan Bola" << endl;
cout << "Panjang jari-jari bola = ";
cin >> a;
volum = 4/3 * phi * a * a * a;
luas = 4 * phi * a * a;
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 4:
cout << "Perhitungan Volume dan Luas Permukaan Limas Segi Empat" << endl;
cout << "Panjang alas limas = ";
cin >> a;
cout << "Lebar alas limas = ";
cin >> b;
cout << "Tinggi limas = ";
cin >> c;
volum = (a * b * c * 1/3);
luas = ((a + b) * c) + (a * b);
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 5:
cout << "Perhitungan Volume dan Luas Permukaan Tabung" << endl;
cout << "Panjang jari-jari alas tabung = ";
cin >> a;
cout << "Tinggi tabung = ";
cin >> b;
volum = phi * a * a * b;
luas = (phi * a * 2) * (b * a);
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 0:
loop = false;
break;
}
cout << endl << "Tekan enter untuk kembali ke menu awal" << endl;
getch();
}
return 0;
}
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
const float phi=3.14;
int main()
{
int iter=0, pil, a, b, c;
float volum, luas;
bool loop=true;
while(loop)
{
clrscr();
cout << "Selamat datang di program hitung"<< endl;
cout << "Anda berada pada iterasi ke-"<< iter << endl;
cout << endl;
cout << ">> Pilihan Menu: "<< endl;
cout << "1) Kubus "<< endl;
cout << "2) Balok"<< endl;
cout << "3) Bola"<< endl;
cout << "4) Limas segi empat"<< endl;
cout << "5) Tabung"<< endl;
cout << "0) Keluar dari program"<< endl;
cout << endl;
cout << "Silahkan masukkan angka pilihan anda: ";
cin >> pil;
switch(pil)
{
case 1:
cout << "Perhitungan Volume dan Luas Permukaan Kubus" << endl;
cout << "Panjang rusuk kubus = ";
cin >> a;
volum = a*a*a;
luas = a*a*6;
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 2:
cout << "Perhitungan Volume dan Luas Permukaan Balok" << endl;
cout << "Panjang balok = ";
cin >> a;
cout << "Lebar balok = ";
cin >> b;
cout << "Tinggi balok = ";
cin >> c;
volum = a*b*c;
luas = ((a * b) + (b * c) + (c * a)) * 2;
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 3:
cout << "Perhitungan Volume dan Luas Permukaan Bola" << endl;
cout << "Panjang jari-jari bola = ";
cin >> a;
volum = 4/3 * phi * a * a * a;
luas = 4 * phi * a * a;
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 4:
cout << "Perhitungan Volume dan Luas Permukaan Limas Segi Empat" << endl;
cout << "Panjang alas limas = ";
cin >> a;
cout << "Lebar alas limas = ";
cin >> b;
cout << "Tinggi limas = ";
cin >> c;
volum = (a * b * c * 1/3);
luas = ((a + b) * c) + (a * b);
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 5:
cout << "Perhitungan Volume dan Luas Permukaan Tabung" << endl;
cout << "Panjang jari-jari alas tabung = ";
cin >> a;
cout << "Tinggi tabung = ";
cin >> b;
volum = phi * a * a * b;
luas = (phi * a * 2) * (b * a);
cout << "Volume = " << volum << endl;
cout << "Luas permukaan = " << luas << endl;
break;
case 0:
loop = false;
break;
}
cout << endl << "Tekan enter untuk kembali ke menu awal" << endl;
getch();
}
return 0;
}