Didalam program ini user menginputkan tinggi dan jari - jari untuk bangun A dan bangun B. kemudian program mengeksekusinya sehingga akan di ketahui luas permukaan dan volume bangun A maupun bangun B, sesuai tinggi dan jari - jari yang telah di inputkan.
Berikut contoh programnya :
Berikut contoh programnya :
import java.io.*;
class fauyan {
double r,s,t;
double phi = 3.14;
double volumekerucut, volumetabung;
double luaskerucut, luastabung;
/*
Email : f_zan.hack@yahoo.com
Web : fzan-aquana.blogspot.com
fauzanvs.blogspot.com
*/
void hitung() {
luaskerucut = (phi * r) * (s + r);
luastabung = (phi* r * 2) * (t + r);
System.out.println(" ");
System.out.println(" Luas Permukaan Kerucut : " +luaskerucut +" cm^2");
System.out.println(" Luas Permukaan Tabung : " +luastabung +" cm^2");
System.out.println(" ");
volumekerucut = (phi * r * r * t) / 3;
volumetabung = t * r * r * phi;
System.out.println(" Volume Kerucut : " +volumekerucut +" cm^3");
System.out.println(" Volume Tabung : " +volumetabung +" cm^3");
System.out.println("==================================================");
}
}
class responsi {
public static void main(String[] args) throws IOException {
BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
fauyan a = new fauyan();
fauyan b = new fauyan();
try{
System.out.println(" MENGHITUNG BANGUN KERUCUT & TABUNG");
System.out.println("==================================================");
System.out.print ("Masukan Tinggi Bangun A = ");
a.t = Integer.parseInt(dataIn.readLine());
System.out.print ("Masukan Jari - Jari Bangun A = ");
a.r = Integer.parseInt(dataIn.readLine());
a.s= Math.sqrt((a.r * a.r)+(a.t * a.t));
System.out.println(" ");
System.out.print ("Masukan Tinggi Bangun B = ");
b.t = Integer.parseInt(dataIn.readLine());
System.out.print ("Masukan Jari - Jari Bangun B = ");
b.r = Integer.parseInt(dataIn.readLine());
b.s= Math.sqrt((b.r * b.r)+(b.t * b.t));
System.out.println("==================================================");
System.out.println(" ");
System.out.println("------------------- Bangun A ----------------------");
System.out.println(" Tinggi Bangun A : " +a.t +" cm");
System.out.println(" Jari - Jari Bangun A : " +a.r +" cm");
System.out.println(" Sisi Miring Bangun A : " +a.s +" cm");
a.hitung();
System.out.println(" ");
System.out.println("------------------- Bangun B ----------------------");
System.out.println(" Tinggi Bangun B : " +b.t +" cm");
System.out.println(" Jari - Jari Bangun B : " +b.r +" cm");
System.out.println(" Sisi Miring Bangun B : " +b.s +" cm");
b.hitung();
}catch( NumberFormatException e ){
System.out.println("Salah Inputan!");
System.exit(1);
}
}
}
class fauyan {
double r,s,t;
double phi = 3.14;
double volumekerucut, volumetabung;
double luaskerucut, luastabung;
/*
Email : f_zan.hack@yahoo.com
Web : fzan-aquana.blogspot.com
fauzanvs.blogspot.com
*/
void hitung() {
luaskerucut = (phi * r) * (s + r);
luastabung = (phi* r * 2) * (t + r);
System.out.println(" ");
System.out.println(" Luas Permukaan Kerucut : " +luaskerucut +" cm^2");
System.out.println(" Luas Permukaan Tabung : " +luastabung +" cm^2");
System.out.println(" ");
volumekerucut = (phi * r * r * t) / 3;
volumetabung = t * r * r * phi;
System.out.println(" Volume Kerucut : " +volumekerucut +" cm^3");
System.out.println(" Volume Tabung : " +volumetabung +" cm^3");
System.out.println("==================================================");
}
}
class responsi {
public static void main(String[] args) throws IOException {
BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
fauyan a = new fauyan();
fauyan b = new fauyan();
try{
System.out.println(" MENGHITUNG BANGUN KERUCUT & TABUNG");
System.out.println("==================================================");
System.out.print ("Masukan Tinggi Bangun A = ");
a.t = Integer.parseInt(dataIn.readLine());
System.out.print ("Masukan Jari - Jari Bangun A = ");
a.r = Integer.parseInt(dataIn.readLine());
a.s= Math.sqrt((a.r * a.r)+(a.t * a.t));
System.out.println(" ");
System.out.print ("Masukan Tinggi Bangun B = ");
b.t = Integer.parseInt(dataIn.readLine());
System.out.print ("Masukan Jari - Jari Bangun B = ");
b.r = Integer.parseInt(dataIn.readLine());
b.s= Math.sqrt((b.r * b.r)+(b.t * b.t));
System.out.println("==================================================");
System.out.println(" ");
System.out.println("------------------- Bangun A ----------------------");
System.out.println(" Tinggi Bangun A : " +a.t +" cm");
System.out.println(" Jari - Jari Bangun A : " +a.r +" cm");
System.out.println(" Sisi Miring Bangun A : " +a.s +" cm");
a.hitung();
System.out.println(" ");
System.out.println("------------------- Bangun B ----------------------");
System.out.println(" Tinggi Bangun B : " +b.t +" cm");
System.out.println(" Jari - Jari Bangun B : " +b.r +" cm");
System.out.println(" Sisi Miring Bangun B : " +b.s +" cm");
b.hitung();
}catch( NumberFormatException e ){
System.out.println("Salah Inputan!");
System.exit(1);
}
}
}
:13
ReplyDelete