Menghitung Luas dan Volume Balok dengan Java
Contoh Program Luas dan Volume Bangun Balok versi Java
import java.util.*;
class balokcetak
{
public int A,
B, C;
int alas, permukaan, vol;// diagonal1,
diagonal2;
public void
input (int a, int b, int c)
{
alas=a*b;
permukaan=2*(a*b+b*c+a*c);
vol=a*b*c;
// diagonal1=Math.sqrt(a);
// diagonal2=Math.sqrt(b);
}
public void
input ()
{
A=0;
B=0;
C=0;
alas=A*B;
permukaan=2*(A*B+B*C+A*C);
vol=A*B*C;
}
}
class proses extends balokcetak
{
public void
cetak()
{
System.out.println("Luas
Alas ="+alas);
System.out.println("Luas
Permukaan ="+permukaan);
System.out.println("Volume
="+vol);
//System.out.println("Diagonal
Alas ="+diagonal1);
// System.out.println("Diagonal
Ruang ="+diagonal2);
}
}
public class balok
{
public static void
main(String[] args)
{
int a,b,c;
Scanner
input=new Scanner(System.in);
System.out.print("Panjang
:");
a=input.nextInt();
System.out.print("Lebar
:");
b=input.nextInt();
System.out.print("Tinggi
:");
c=input.nextInt();
proses
op=new proses();
op.input(a,b,c);
op.cetak();
}
}
0 komentar:
Posting Komentar