import java.util.Scanner; public class VolumeBola { public static void main (String[] args) { Scanner nominal = new Scanner(System.in); int r; System.out.println(" "); System.out.println("Menghitung Volume Bola"); System.out.println("+------------------------------------+"); System.out.println("| (Rumus Volume Bola ? 4/3 x phi x r3|"); System.out.println("+------------------------------------+"); System.out.print("masukkan jari-jari (r)\t= "); r = nominal.nextInt(); if (r < 0 ) { System.out.println("nilai tidak boleh kecil dari 0"); System.out.println("jika nilai yang anda masukkan tidak sesuai"); System.out.println("Program tidak akan bekerja sebagaimana mestinya !"); System.out.print("masukkan kembali nilai sisi pendek\t= "); r = nominal.nextInt(); } else if (r > 0) { System.out.print(" "); } double phi,r3,VolumeBola; phi = 3.14; r3 = r * r * r; VolumeBola = 4 / 3 * phi * r3; System.out.println("Diketahui"); System.out.println("---------"); System.out.println("phi\t\t= 22/7"); System.out.println("jari-jari\t="+r); System.out.println("Penyelesaian"); System.out.println("------------"); System.out.println("\t\tr3 = r x r x r"); System.out.println("\t\t = " + r3); System.out.println("Volume Bola\t = 4/3 x phi x r3 "); System.out.println("\t\t = 4/3 x 3.14 x "+ r3); System.out.println("\t\t = "+(4 * phi / 3 * r3)); } }
mencari volume bola dengan java
January 18, 2014
Bobby Syahronanda
0 Comments