Question: Alter the circle class provided here to include a compareTo method. Make any other changes you need to the class, but DO NOT change the
Alter the circle class provided here to include a compareTo method. Make any other changes you need to the class, but DO NOT change the toString method (or your output will be wrong). Add code to the main method as specified.
import java.util.Scanner;
public class Lab7Num1
{public static class Circle { //attribute private double radius; //constructors public Circle() {radius=0.0; } public Circle(double r) {radius=r; } //accessors public double getRadius() { return radius; } //mutators public void setRadius(double r) { radius = r; } //methods public double circumference() { return 2*Math.PI*radius; } public double area() { return Math.PI*radius* radius; } public String toString() { return "Circle of radius " + radius; } public int compareTo(Circle c) { //write your code here } } public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
