Question
write in Java program Write a program that does the following:Use the provided class, CircleCalculator, as well as the classes Random, Math, and NumberFormat to
write in Java program
- Write a program that does the following:Use the provided class, CircleCalculator, as well as the classesRandom, Math, and NumberFormat to accomplish the following:
- 1) Create an object of the class CircleCalculator
- 2) Create 10 variables of type double: radiusA, area1A, circumference1A, area2A, circumference2A, radiusB, area1B, circumference1B, area2B, circumference2B
- 3) Use Random class to generate values in the following ranges for radiusA and RadiusB.
Radius Name | Generate a random double in the range |
radiusA | 1 radius |
radiusB | 0 radius |
4) For each radius, calculate the area and the circumference of a circle by calling the available methods
two times.
a) For radiusA
-
- i) To calculate area1A and circumference1A, use a value of 3.142 for Pi,
- ii) To calculate area2A and circumference2A, use the value of Pi based on the built in Math constant value of Pi
- b) For radiusB
- i) To calculate area1B and circumference1B, use a value of 3.142 for Pi,
- ii) To calculate area2B and circumference2B, use the value of Pi based on the built in Math constant value of Pi.
5) Output the four sets of data using the following specification for how to format the values
- a) Value of Radius you calculate formatted to 4 Decimal places
- b) Pi format to 10 Decimal places if the digit exists
- c) Area formatted to 4 Decimal places
- d) Circumference formatted to 4 Decimal places
6) Example Output. Do not make your output the same as mine but use text to indicate what all the
outputs are.
RadiusA of 1.2270
Value of 3.142 for Pi
Area A = 4.7306
Circumference A = 7.7106
Value of 3.14159265359 for Pi
Area A = 4.7300
Circumference A = 7.7096
RadiusB of 3.3642
Value of 3.142 for Pi
Area B = 35.5601
Circumference B = 21.1405
Value of 3.14159265359 for Pi
Area B = 35.5555
Circumference B = 21.137
write in java program and just use print or println statement
public static class Circlecalculator * paran radius value for radius * @paran PI approxination/value for pi * @return area of a circle with specified radius, for a specified PI public double area(double radius, double PI) return PI radiusradius; * paran radius value for the radius * @paran PI approxination/value for pi * greturn circumference of a circle with specified radius, for a *specified P public double circumferenceldouble radius, double PI) return 2.0 PI radiusStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started