Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help me with java ! this should ve two files Circle &circle app Circle -c

ID: 3681354 • Letter: P

Question

please help me with java !

this should ve two files Circle &circle app

Circle -color: String -radius: double -PI-3.14159 +Circle) +Circle (radius:double color:String) +getColor):String +getRadius):double +setColor(String):void +setRadius(double):void +findArea):double +findCircumference():double +findSurfaceArea():double +findVolume(:double 1) Create a class called Circle using the UML class diagram given above. PI should be declared as a constant (please use your own declared constant for this lab, rather than Math.PID) The class contains two constructors - one that set the data properties to the default (assume default radius is 1.0 and the default color is white) and the 2-arg consructor sets the data properties to the values passed in. In addition, add the get/set methods and the find methods given in the UML diagram. (yes, this is a Circle class, but we can still use the data properties to calculate values for a Sphere...) Circumference 2 . . radius = . diameter Sphere Surface Area : 4 . -r2--d2 S 4/3 . . r33( -d 3)/6 phere Volume -

Explanation / Answer

/************ Circle.java ****************/

public class Circle {
private Double radius;
private String color;
private Double PI = 3.14159;

public Circle() {
radius = 1.0;
color = "White";
}

public Circle(Double radius, String color) {
this.radius = radius;
this.color = color;
}

public Double getRadius() {
return radius;
}

public void setRadius(Double radius) {
this.radius = radius;
}

public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public Double findArea() {

return (double)Math.round(radius * radius * PI * 1000d) / 1000d;
}

public Double findCircumference() {
return (double)Math.round(2 * PI * radius * 1000d) / 1000d;
}

public Double findSurfaceArea() {
return (double)Math.round(4 * PI * radius * radius * 1000d) / 1000d;
}

public Double findVolume() {
return (double)Math.round((4 * PI * radius * radius * radius)/3 * 1000d) / 1000d;
}

}

/********** CircleApp.java ***************/

import java.util.Scanner;


public class CircleApp {

   public static void main(String[] args) {

       Scanner input = new Scanner(System.in);
String color;
Double radius;

       Circle circle1 = new Circle();
       System.out.println(" Circle 1:");
       System.out.println("Color: "+circle1.getColor());
       System.out.println("Radius: "+circle1.getRadius());
       System.out.println("Area: "+circle1.findArea());
       System.out.println("Circumference: "+circle1.findCircumference());
       System.out.println("Surface Area: "+circle1.findSurfaceArea());
       System.out.println("Volume: "+circle1.findVolume());


       System.out.println(" Circle 2:");
       System.out.print("Enter the Radius of the circle2: ");
       radius = input.nextDouble();
       System.out.print("Enter the Color of the circle2: ");
       color = input.next();
       Circle circle2 = new Circle(radius,color);

       System.out.println("Color: "+circle2.getColor());
       System.out.println("Radius: "+circle2.getRadius());
       System.out.println("Area: "+circle2.findArea());
       System.out.println("Circumference: "+circle2.findCircumference());
       System.out.println("Surface Area: "+circle2.findSurfaceArea());
       System.out.println("Volume: "+circle2.findVolume());
      
   }
  
}