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

Hello, I need help with a problem. I will post a program that has introduced us

ID: 3853636 • Letter: H

Question

Hello, I need help with a problem. I will post a program that has introduced us to UMF and using a tester for our code. This code is called Rectangle and my professor would like use to do a similiar code but instead doing it on a Circle. I will show the UMF for the rectangle and then the code, and what i need is a code for a circle, which i will post the UMF diagram for the circle as well at the bottom. Thank you! (circle that grows in size to a certain size, and then shrinks back.)

Example (Rectangle):

public class Rectangle

{

private double width;

private double height;

public Rectangle()

{

width = 1;

height = 1;

}

public Rectangle(double w, double h)

{

width = w;

height = h;

}   

//mutators or setters

public void setWidth(double newWidth)

{

width = newWidth;

}

public void setHeight(double newHeight)

{

height = newHeight;

}

//accessor or getters

public double getWidth()

{

return width;

}

import java.util.*;

public class RectangleDriver

{

public static void main(String[] args)

{

Rectangle r2 = new Rectangle(2,3);

//double area = r2.getArea();

//Rectangle r3 = new Rectangle(6,7);

//boolean result = r2.equals(r3);

//System.out.println(r);

Rectangle[] r = new Rectangle[2];

fillArray(r);

printArray(r);

}

public static void printArray(Rectangle[] r)

{

for (int i = 0; i < r.length; i++)

{

System.out.println(r[i].toString());

}

}

public static void fillArray(Rectangle[] recs)

{

Scanner kb = new Scanner(System.in);

for (int i = 0; i < recs.length; i++)

{

System.out.println("Enter the width: ");

double w = kb.nextDouble();

System.out.println("Enter the height: ");

double h = kb.nextDouble();

Rectangle r = new Rectangle(w,h);

recs[i] = r;

}   

}

}   

-------------------------------------------------------------------------------------

WHAT I NEED (CIRCLE):

-width: Double - height: double + Rectangle 0 +Rectangle (double w, double h) +get width 0 double +get height 0 double +set width 0 double w +set height O: doubleh ToString QiString + get Area 0 double + get perimeter 0: double

Explanation / Answer

public class Circle
{
private double radius

public Circle()
{
radius = 1;
}
public Circle(radius r)
{
radius = r;
}   
//mutators or setters
public void setradius(double newradius)
{
radius = newradius;
}

//accessor or getters
public double getradius()
{
return radius;
}

public double getArea()
{
double a=(pi*r*r);
return double;
}
public double getCircumference()
{
double a=(2*pi*r);
return double;
}
public double getDiameter()
{
double a=(2*r);
return double;
}
public double getExpand()
{
y = 9/4 * a(old area).
return double;
}

public double getShrink()
{
p=(pi*r*r)-pi*(xr/100)*(xr/100);
return double;
}


import java.util.*;
public class CircleDriver
{
public static void main(String[] args)
{
Rectangle r2 = new Circle(2);
//double area = r2.getArea();
Rectangle r3 = new Circle(2);
//double area = r3.getCircumference();
Rectangle r4 = new Circle(2);
//double area = r4.getDiameter();
Rectangle r5 = new Circle(2);
//double area = r5.getExpand();
Rectangle r6 = new Circle(2);
//double area = r6.getshrink();

//System.out.println(r);
//System.out.println(r2);
//System.out.println(r3);
//System.out.println(r4);
//System.out.println(r5);
//System.out.println(r6);

Circle[] r = new Circle[2];
fillArray(r);
printArray(r);
}
public static void printArray(Circle[] r)
{
for (int i = 0; i < r.length; i++)
{
System.out.println(r[i].toString());
}
}

for expand the circle
--------------------------------------------------------------------

Circumference = 2 * pie * radius
Area = pie * radius * radius

new circumference = 3 * pie * radius = 150 times of old circumference

so new radius = 3/2 * radius


new area = 9/4 * old area.
-----------------------------------------------------------------------

for shrink the circle need to be amount of radius to be decreases

let the amount of shirnk is X%
p=(pi*r*r)-pi*(xr/100)*(xr/100);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote