Java Codes
--+o0O0o+--
Write
a program that reads in the radius of a circle and the compute and display the
diameter, circumference and area. Use the constant value 3.14159 for ( pi ) π .
Code:
import java.util.Scanner;
public class MachineProblem4 {
public static
void main(String[] args) {
Scanner
input_user = new Scanner(System.in);
int
radius,diameter;
double
PI,circum,area;
System.out.print("Enter radius: ");
radius =
input_user.nextInt();
PI =
3.14159;
diameter =
radius * 2;
circum = PI * diameter;
area = PI *
(radius * radius);
System.out.println("******************************************");
System.out.println(" Diameter --------> " + diameter );
System.out.println("******************************************");
System.out.println(" Circumference ---> " + circum);
System.out.println("******************************************");
System.out.println(" Area ------------> " + area);
System.out.println("******************************************");
}
}
Walang komento:
Mag-post ng isang Komento