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

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 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.

}

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

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 10.

Using Math.random( ) and for loop to create 10 Square objects to be stored in the array so the length of the edge of each square is between 7 and 17 inclusively.

Display the information for the 10 Square objects (the lengths of the edges, diameters, perimeters, and areas on the console).

Sort the 10 Square objects in increasing order based on the lengths of the edges of the 10 Square objects.

Redisplay the information for the 10 Square objects (the lengths of the edges, diameters, perimeters, and areas 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 Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions