Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Circle.java class Circle { private double radius; private double area; private double diameter; Circle() { } public void setRadius(double r) { } public double getRadius()

image

Circle.java

class Circle { private double radius; private double area; private double diameter; Circle() { } public void setRadius(double r) { } public double getRadius() { } private void computeDiameter() { } private void computeArea() { } public double getDiameter() { } public double getArea() { }}

TestCircle.java

class TestCircle { public static void main (String args[]) { Circle a = new Circle(); Circle b = new Circle(); Circle c = new Circle();

a.setRadius(1.5); b.setRadius(1500.50);

System.out.println("The area of a is" + a.getArea()); System.out.println("The diameter of ais " + a.getDiameter()); System.out.println("The area of b is " + b.getArea()); System.out.println("The diameter of bis " + b.getDiameter()); System.out.println("The area of c is "+ c.getArea()); System.out.println("The diameter of cis " + c.getDiameter()); }}

Programming Exercise 4-6 C Instructions Ll Create a class named circle with fields named radius, diameter, and area. Include a constructor that sets the radius to 1 and calculates the other two values. Also include methods named setRadius() and getRadius (). The setRadius() method not only sets the radius, but it also calculates the other two values. (The diameter of a circle is twice the radius, and the area of a circle is pi multiplied by the square of the radius. Use the Math class PI constant for this calculation.) Grading Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade. Once you are happy with your results, click the Submit button to record your score. Circle.java 1 class Circle { 2 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19} 20 TestCircle.java private double radius; private double area; private double diameter; Circle() { } public void setRadius (double r) { } public double getRadius() { } private void computeDiameter() { } private void computeArea() { } public double getDiameter() { } public double getArea() { } +

Step by Step Solution

3.44 Rating (144 Votes )

There are 3 Steps involved in it

Step: 1

Circlejava class Circle attributes private double radius private double area private double diameter ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Programming questions

Question

Find the lengths of the curves. x = (y 3 /12) + (1/y), 1 y 2

Answered: 1 week ago

Question

Maintain five-figure accuracy

Answered: 1 week ago

Question

Maintain five-figure accuracy

Answered: 1 week ago