Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!