Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a toString method for this class. The method should return a string containing the radius and area of the circle. 2. Write an

1. Write a toString method for this class. The method should return a string containing the radius and area of the circle.

2. Write an equals method for this class. The method should accept a Circle object as an argument. It should return true if the argument object contains the same data as the calling object, or false otherwise.

3. Write a greaterThan method for this class. The method should accept a Circle object as an argument. It should return true if the argument object has an area that is greater than the area of the calling object, or false otherwise.

This is what I have but I have ONE error that I can't figure out how to fix: The error is line 3, where it says private double radius. When I use the suggested fix on Netbeans (which changes it to private final double radius) I just another error saying illegal use of expression or something. Can someone help???

public class Circle { { private double radius;

public Circle(double r) { radius = r; }

public double getArea() { return Math.PI * radius * radius; }

public double getRadius() { return radius; } public String toString() { String str; str = "Radius: " + radius + "Area: " + getArea(); return str; } public boolean equals(Circle c) { boolean status; if(c.getRadius() == radius) status = true; else status = false; return status; } public boolean greaterThan(Circle c) { boolean status; if(c.getArea() > getArea()) status = true; else status = false; return status; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

3. Develop a case study.

Answered: 1 week ago