import java.text.*;
public class Circle
{
public static void main (String[] args)
{
// create decimal format
DecimalFormat DF = new DecimalFormat ("0.00000");
// Radius is the radius of the circle
// Diam is diameter
// Circum is circumference
// Area is area of circle
double Radius = 6.75;
double Diam;
double Circum;
double Area;
// PI is constant 3.14159
final double PI = 3.14159;
// calculate diameter
Diam = 2 * Radius;
// calculate circumference
Circum = PI * Diam;
// calculate area
Area = PI * Radius * Radius;
// display intro message
System.out.println("This program calculates Diameter, Circumference, and Area of a circle");
// display the result
System.out.println("Radius constant = " + DF.format(Radius));
System.out.println("Diameter = " + DF.format(Diam));
System.out.println("Circumference = " + DF.format(Circum));
System.out.println("Area = " + DF.format(Area));
// display end message
System.out.println("End of program");
}
}
public class Circle
{
public static void main (String[] args)
{
// create decimal format
DecimalFormat DF = new DecimalFormat ("0.00000");
// Radius is the radius of the circle
// Diam is diameter
// Circum is circumference
// Area is area of circle
double Radius = 6.75;
double Diam;
double Circum;
double Area;
// PI is constant 3.14159
final double PI = 3.14159;
// calculate diameter
Diam = 2 * Radius;
// calculate circumference
Circum = PI * Diam;
// calculate area
Area = PI * Radius * Radius;
// display intro message
System.out.println("This program calculates Diameter, Circumference, and Area of a circle");
// display the result
System.out.println("Radius constant = " + DF.format(Radius));
System.out.println("Diameter = " + DF.format(Diam));
System.out.println("Circumference = " + DF.format(Circum));
System.out.println("Area = " + DF.format(Area));
// display end message
System.out.println("End of program");
}
}
No comments:
Post a Comment