Malam,,
Kali ini ane mau share dikit nih tentang pemrograman C++. kali aja ada yang membutuhkan..
Program ini berguna utk menghitung segala jenis bangun ruang. Ok langsung saja, CEKIDOT...
****************************************************************************
#include<iostream>
#include<conio.h>
using namespace std;
int main(void)
{
float lpkubus, pilih, s, l, ls, la, r, p, t, lk, v;
float phi = 3.14;
char status;
string nama;
cout << "\t\t\t** Rumus Pada Bangun Ruang **"<<endl;
cout << "\t\t=============================================="<<endl;
cout << "\nSilahkan Masukkan Nama Anda : ";
getline(cin, nama);
cout <<endl;
menu :
cout << "\tMenu Utama :" << endl;
cout << "\t\t1. Kubus "<< endl;
cout << "\t\t2. Balok "<< endl;
cout << "\t\t3. Tabung "<<endl;
cout << "\t\t4. Bola "<<endl;
cout << "\t\t5. Kerucut "<<endl;
cout << "\t\t6. Prisma "<<endl;
cout << "\t\t7. Limas Segitiga "<<endl;
cout << "\t\t8. Limas Segiempat "<<endl;
cout << endl;
cout << "Terima Kasih "<<nama<<", Silahkan Masukkan Menu yang Anda Pilih : ";
cin >> pilih;
if (pilih==1)
{
Kubus :
cout <<endl;
cout << "\t\t- Kubus -"<<endl;
cout << "\t\t================"<<endl;
cout <<endl;
cout << "\tMasukkan Besar Sisi Kubus : ";
cin >> s;
cout << endl;
v = s*s*s;
cout << "\tVolume = S * S * S = S^3"<<endl;
cout << "\tVolume = " << v;
cout << endl;
l = s*s;
cout << "\n\tLuas = S * S = S^2"<<endl;
cout<<"\tL = "<<s<<"*"<<s<<"*"<<s<<"\n";
cout<<"\tL = "<<l;
cout<<endl;
lpkubus = 6*s*s;
cout << "\n\tLuas Permukaan Kubus = 6 * S * S"<<endl;
cout << "\tLuas Permukaan = "<<lpkubus;
cout << endl;
cout << "\nApakah Anda Ingin Memilih Kembali ? (Y=Ya /T=Tidak /M=Menu Utama) : ";
cin >> status;
cout <<endl;
if(status =='y' || status =='Y')
goto Kubus;
else if (status == 'm' || status == 'M')
goto menu;
else goto end;
}
else if (pilih==2)
{
Balok :
cout << endl;
cout << "\t\t+ Balok +"<<endl;
cout << "\t\t==========="<<endl;
cout << endl;
cout << "\tMasukkan Panjang Balok : ";
cin >> p;
cout << "\n\tMasukkan Lebar Balok : ";
cin >> l;
cout << "\n\tMasukkan Tinggi Balok : ";
cin >> t;
cout << endl;
l = 2*(p*l+p*t+l*t);
cout << "Rumus :\n\t Luas = 2 * (p * l + p * t + l * t"<<endl;
cout << "\n\t\tLuas = " <<l;
cout<<endl;
cout << "\nApakah Anda Ingin Memilih Kembali ? (Y=Ya /T=Tidak /M=Menu Utama) : ";
cin >> status;
cout << endl;
if(status =='y' || status =='Y')
goto Balok;
else if (status == 'm' || status == 'M')
goto menu;
else
goto end;
}
else if (pilih==3)
{
Tabung :
cout <<endl;
cout << "\t\t- Tabung -"<<endl;
cout << "\t\t================="<<endl;
cout << "\tMasukkan jari-jari alas tabung : ";
cin >> r;
cout << "\tMasukkan tinggi tabung : ";
cin >> t;
v= phi*r*r*t;
cout << "\tRumus : \n\tV = phi * r * r *t = p.r^2.t"<<endl;
cout << "\n\tVolume = 3.14 * " << r << " * " << r << " * " << t << ""<<endl;
cout << "\n\tVolume = " <<v<<endl;
cout << "\nApakah Anda Ingin Memilih Kembali ? (Y=Ya /T=Tidak /M=Menu Utama) : ";
cin >> status;
cout << endl;
if(status =='y' || status =='Y')
goto Tabung;
else if (status == 'm' || status == 'M')
goto menu;
else
goto end;
}
else if (pilih==4)
{
Bola :
cout << endl;
cout << "\t\t=*= Bola =*="<<endl;
cout << "\t\t=============="<<endl;
cout << "\tMasukkan Jari-jari Bola : ";
cin >> r;
l = 4*phi*r*r;
v = 1.33*phi*r*r*r;
cout << "\tLuas = 4*phi*r*r"<<endl;
cout << "\tLuas = 4*3.14*"<<r<<"*"<<r<<""<<endl;
cout << "\tLuas = "<<l<<endl;
cout << "\n\tVolume = 4/3 * phi * r * r * r"<<endl;
cout << "\n\tVolume = 4/3 * 3.14 * " << r << " * " << r << " * "<<r<<""<<endl;
cout << "\n\tVolume = "<<v<<endl;
cout << "\nApakah Anda Ingin Memilih Kembali ? (Y=Ya /T=Tidak /M=Menu Utama) : ";
cin >> status;
cout << endl;
if(status =='y' || status =='Y')
goto Bola;
else if (status == 'm' || status == 'M')
goto menu;
else
goto end;
}
else if(pilih==5)
{
Kerucut :
cout << "\t\t======= Kerucut ======="<<endl;
cout << "\t\t+++++++++++++++++++++++"<<endl;
cout << "\tMasukkan Jari-jari Kerucut = ";
cin >> r;
cout << "\tMasukkan Selimut Kerucut : ";
cin >> s;
la = phi*r*r;
ls = phi*r*s;
lk = la+ls;
cout << "\tLuas Alas Kerucut : "<<la<<endl;
cout << "\tLuas Selimut erucut : "<<ls<<endl;
cout << " \tLuas Permukaan Kerucut : "<<lk<<endl;
cout << "\nApakah Anda Ingin Memilih Kembali ? (Y=Ya /T=Tidak /M=Menu Utama) : ";
cin >> status;
cout << endl;
if(status =='y' || status =='Y')
goto Kerucut;
else if (status == 'm' || status == 'M')
goto menu;
else
goto end;
}
else if (pilih==6)
{
Prisma :
cout << "\t\t----- Prisma -----"<<endl;
cout << "\t\t##################"<<endl;
cout << "\tMasukkan Luas Alas = ";
cin >> la;
cout << endl;
cout <<"\tMasukkan Luas Sisi Tegak = ";
cin >> s;
cout << endl;
cout << "\tMasukkan Tinggi = ";
cin >> t;
cout <<endl;
l = (2*la)+ls;
v = la*t;
cout << "\tLuas Prisma = "<<l<<endl;
cout << "\tVolume = "<<v<<endl;
cout << "\nApakah Anda Ingin Memilih Kembali ? (Y=Ya /T=Tidak /M=Menu Utama) : ";
cin >> status;
cout << endl;
if(status =='y' || status =='Y')
goto Prisma;
else if (status == 'm' || status == 'M')
goto menu;
else
goto end;
}
else if (pilih==7)
{
Limas_Segitiga :
cout << "\t\t***** Limas Segitiga *****"<<endl;
cout << "\t\t+++++++++++++++++"<<endl;
cout << "\tMasukkan Luas Alas = ";
cin >> la;
cout << endl;
cout << "\tMasukkan Luas 'n' Segitiga = ";
cin >> ls;
cout << endl;
cout << "\tMasukkan Tinggi = ";
cin >> t;
cout << endl;
l = la*ls;
v = 0.33*la*t;
cout << "\tLuas Limas Segitiga = "<<l<<endl;
cout << "\tVolume Limas Segitiga = "<<v<<endl;
cout << "\nApakah Anda Ingin Memilih Kembali ? (Y=Ya /T=Tidak /M=Menu Utama) : ";
cin >> status;
cout << endl;
if(status =='y' || status =='Y')
goto Limas_Segitiga;
else if (status == 'm' || status == 'M')
goto menu;
else
goto end;
}
else if(pilih==8)
{
Limas_Segiempat :
cout << "\t\t***** Limas Segiempat *****"<<endl;
cout << "\t\t-+-+-+-+-+-+-+-+-+-+-+-+-+-"<<endl;
cout << "\tMasukkan Luas Alas = ";
cin >> la;
cout << endl;
cout << "\tMasukkan Luas 'n' Segiempat = ";
cin >> ls;
cout << endl;
cout << "\tMasukkan Tinggi = ";
cin >> t;
cout << endl;
l = la*ls;
v = 0.33*la*t;
cout << "\tLuas Limas Segiempat = "<<l<<endl;
cout << "\tVolume Limas Segiempat = "<<v<<endl;
cout << "\nApakah Anda Ingin Memilih Kembali ? (Y=Ya /T=Tidak /M=Menu Utama) : ";
cin >> status;
cout << endl;
if(status =='y' || status =='Y')
goto Limas_Segiempat;
else if (status == 'm' || status == 'M')
goto menu;
else
goto end;
}
else
{
cout << "\n\n\tMenu yang Anda Pilih Salah"<<endl;
cout << "\nSilahkan Kembali ke Menu Utama (Y=Ya / T=Tidak) : ";
cin >> status;
cout << endl;
if(status =='y' || status =='Y')
goto menu;
else
goto end;
}
end :
cout << "\n ++ PROJECT KITSUNE IT ++ "<<endl;
cout << " ======================== "<<endl<<endl;
cout << "Bergerak di Bidang IT Teknologi"<<endl;
cout << "Memajukan Bangsa di Dunia IT Teknologi dan Sharing ke Orang yang Belum Mengenal Teknologi"<<endl<<endl;
system("PAUSE");
return 0;
getch();
*********************************************************************************
Note : Apabila script di atas mengalami error, Silahkan lapor dikolom komentar ya
Semoga Bermanfaat.
Pemrograman C++ (Kalkulator Bangun Ruang)
Label: Pemograman
No comments:
Post a Comment