Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following FigureGeometry is an interface. You are asked to define a class called Square to implement the interface. The skeleton of the class Square

The following FigureGeometry is an interface. You are asked to define a class called Square to implement the interface. The skeleton of the class Square is given below.

public interface FigureGeometry

{

public static final double squareroot2 = 1.414;

public abstract double perimeter( );

pubic abstract double area( );

}

class Square implements FigureGeometry

{

private double edge; //edge is the length of one edge in a square.

Square( ) { } //the default constructor that sets 1.0 to edge.

Square(double r) { } //a constructor that sets r to edge.

public double getEdge( ) { } //the getter method that returns edge.

public double diameter( ){ } //the method that returns the diameter of a square.

//consider using squareroot2 when defining this method.

public double perimeter( ) { } //the method that returns the perimeter of a square.

public double area( ){ } //the method that returns the area of a square.

}

Moreover, you are asked to write a client program using the Square class. Within your client program you are asked to define a Square array of size 100. Using Math.random( )

and for loop to create 100 Square objects to be stored in the array such that the edge of each square is between 107 and 507 inclusively. Among the 100 Square objects, find the location of the square that has the largest perimeter and display its information, i.e., length of the edge, diameter, perimeter, and area, on the console. Also, find the location of the square that has the smallest perimeter and display its information, i.e., length of the edge, diameter, perimeter, and area, on the console.

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions