Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write
Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle.
The Console Output
Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302
- Write and document your program per class coding conventions.
- Add an instance variable double radius. Generate its get/set methods.
- Manually type the methods getDiameter(), getCircumference(), and getArea(). To calculate the circumference and area, use 3.14159 or the Java defined constant Math.PI
- In main method, create a new instance of Assign3: Assign3 circle = new Assign3();
- Create an instance of Scanner. Call print() to prompt the user to enter the radius. Call input.nextDouble() to get the user input. Call circle.setRadius() to set the radius.
- Then call println() 4 times, each with the value of getRadius, getDiameter, getCircumference, getArea, respectively.
-
Use: setRadius(radius); String results = "Radius is " + getRadius() + ...; circleLabel.setText(results);
Step 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