Rabu, 25 Mei 2011

JAVA program Calculating Area and Volume of Balls

The ball is hand built curved space bounded by a curved area. The ball can be formed from the wake half-circle that rotated as far as 360 ° in diameter.

Algorithm to find the ball wide:

Input the radius = r
Input pi = 3.14
Calculate the area of ​​L = pi * r * r
Print Size L.


Volume ball search algorithm


Input the radius = r
Input pi = 3.14
Calculate the volume V = pi * r * r * r
Print Volume V.

The following program :

import jeliot.io.*;

public class GlobalMembers
{
public static void main()
{
libo x = new libo();
x.masukan();
System.out.print(" hasilnya adalah \n");
x.ngitung();
}
}

public class libo
{
public final void masukan()
{
System.out.print("masukkan nilai r :");
r = Input.readInt();
}
public final void ngitung()
{
pi +=3.14;
volume =(4/3)*pi*r*r*r;
luas =pi*r*r;
System.out.print("luas =");
System.out.print(luas);
System.out.print("\n");
System.out.print("volume =");
System.out.print(volume);
System.out.print("\n");
}
private int r;
private float pi ;
private float volume ;
private float luas ;

}

Tidak ada komentar:

Posting Komentar