Created
March 18, 2014 14:20
-
-
Save pyk/9621000 to your computer and use it in GitHub Desktop.
tugas algoritma dan pemograman - mencari volume bangun kerucut+setengah lingkaran dan prisma+balok
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tujuan | |
// Mencari volume bangun Kerucut dan setengah bola | |
// | |
// Fakta | |
// volume total = volume kerucut + 1/2 volume bola | |
// volume kerucut = 1/3 pi r^2 t | |
// volume bola = 4/3 pi r^2 | |
// | |
// Algoritma | |
// 1. input data r(jari-jari) | |
// 2. inpuit data t(tinggi kerucut) | |
// 2. kalkulasi volume total | |
// 3. output | |
// | |
// Penjelasan tambahan: | |
// fungsi `pow(r,2)` adalah mengkuadratkan jari-jari | |
#include <iostream.h> | |
#include <conio.h> | |
#include <math.h> | |
// deklarasi fungsi main | |
int main() | |
{ | |
// initialisasi variable jari-jari dan tinggi kerucut | |
// yg bernilai integer | |
int r; | |
int t; | |
// initialisasi nilai-nilai yg dibutuhkan saat perhitungan | |
float pi = 3.14; | |
float setengah = 1.0/2.0; | |
float sepertiga = 1.0/3.0; | |
float empatpertiga = 4.0/3.0; | |
// initialisasi nilai-nilai akhir | |
float volume_kerucut; | |
float volume_bola; | |
float volume_total; | |
// menambil data yg dibutuhkan, jari-jari dan tinggi kerucut | |
cout<<"Masukkan nilai jari-jari bangun (r): "; | |
cin>>r; | |
cout<<"Masukkan nilai tinggi kerucut (t): "; | |
cin>>t; | |
// menghitung volume kerucut | |
volume_kerucut = sepertiga * pi * pow(r,2) * t; | |
// menghitung volume bola | |
volume_bola = empatpertiga * pi * pow(r,2); | |
// menghitung volume total | |
volume_total = volume_kerucut + (setengah * volume_bola); | |
// output hasil | |
cout<<"Volume bangun kerucut dan setengah bola = "<<volume_total<<endl; | |
} | |
// semoga bermanfaat | |
// bayu aldi yansyah | |
// S1 Matematika, 2013 | |
// Universitas Airlangga | |
// http://bayu-fst13.web.unair.ac.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tujuan | |
// Mencari volume bangun balok dan prisma | |
// | |
// Fakta | |
// volume total = volume balok + volume prisma | |
// volume prisma = luas alas x tinggi prisma | |
// luas alas prisma = 1/2 x alas x tinggi | |
// volume balok = p x l x t | |
// alas segitiga = lebar balok(l) | |
// tinggi prisma = panjang balok(p) | |
// | |
// Algoritma | |
// 1. input data panjang balok | |
// 2. input data lebar balok | |
// 3. input data tinggi balok | |
// 4. input data tinggi segitiga | |
// 4. kalkulasi volume total | |
// 5. output | |
#include <iostream.h> | |
#include <conio.h> | |
int main() | |
{ | |
// initialisasi variabel | |
int p; | |
int l; | |
int t; | |
int ts; | |
float setengah = 1.0/2.0; | |
float luas_alas; | |
float volume_prisma; | |
float volume_balok; | |
float volume_total; | |
// input data-data yang dibutuhkan | |
// lalu simpan di variabel | |
cout<<"Masukkan nilai panjang balok (p): "; | |
cin>>p; | |
cout<<"Masukkan nilai lebar balok (l): "; | |
cin>>l; | |
cout<<"Masukkan nilai tinggi balok (t): "; | |
cin>>t; | |
cout<<"Masukkan nilai tinggi segitiga (ts): "; | |
cin>>ts; | |
// kalkulasi | |
luas_alas = setengah * l * ts; | |
volume_prisma = luas_alas * p; | |
volume_balok = p * l * t; | |
volume_total = volume_prisma + volume_balok; | |
// output | |
cout<<"Volume bangun prisma dan balok = "<<volume_total<<endl; | |
} | |
// semoga bermanfaat | |
// bayu aldi yansyah | |
// S1 Matematika, 2013 | |
// Universitas Airlangga | |
// http://bayu-fst13.web.unair.ac.id | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment