Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an application that inputs the user the radius of a circle as an Integer a

ID: 3541549 • Letter: W

Question

Write an application that inputs the user the radius of a circle as an Integer and prints the circle's diameter, circumference and area using the floating point value of 3.1459 for Pi. Use the import java.util.Scanner;. This constant is more precise than the value of 3.14159. Clas Math is defined in package java.lang. Classes in the package are imported automatically, so you do not need to import class Math to use it. Use the following formulas (r is the radius) diameter = 2r, circumference=2 Pi r, area = Pi r ^2.

Do not store the results of each calculation in a variable, Rather specify each calculation as the value that will be output in a (System.out.printf) statements. The values produced by the circumference and area calculations are floating numbers. Such values can be output with the format specifier %f in a (System.out.printf) statement.

Explanation / Answer

import java.util.*;
public class circle
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("Enter value of radius");
double r = in.nextDouble();
System.out.printf(" Diameter of circle given by %f", (float)(2*r));
System.out.printf(" circumference of circle given by %f",(float)(2*Math.PI*r));
System.out.printf(" area of circle given by %f",(float)(Math.PI*Math.PI*r));
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote