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

I need in Java. 1. Write a class named Pool to represent a swimming pool. The cl

ID: 3605845 • Letter: I

Question

I need in Java.

1. Write a class named Pool to represent a swimming pool. The class should have private instance fields to store the shape of a pool (oval, rectangular, etc.), length (in feet), width (in feet), depth (in feet), area (in square feet) and the volume (in cubic feet) of the pool. Also provide the following methods:•A default constructor to initialize the instance variables.A Constructor with parameters to initialize the instance variables to the arguments indicated in the parameter list of the constructor. I like this constructor to accept as parameters the shape, length, width, and depth of the pool and set the values for member fields, accordingly.•Appropriate methods to set the value of each of the private instance fields.•Appropriate methods to get the value of each of the private instance fields.•A method to calculate and return the area of the pool. The area is calculated by multiplying length and width. So, area = length * width •A method to calculate and return the volume of the pool. The volume is calculated by multiplying depth by length and width. So, volume = length * width * depth •A method to display the values of all of the variables. This is just a method with a bunch of output statements for all of the instance variables.••Write a main program that uses the class Pool and test various operations on the objects of the class. Perform a series of operations to test each of the methods and the constructors. I need a menu of choices offered to the user for testing the code. Make sure to prompt the user for input as you test your code.

Explanation / Answer

Pool.java

public class Pool {
//Declaring instance variables
private String shape;
private double length;
private double width;
private double height;
private double area;
private double volume;

//Zero argumented constructor
public Pool() {

}

//Getting the input entered by the user
public Pool(String shape, double length, double width, double height) {
super();
this.shape = shape;
this.length = length;
this.width = width;
this.height = height;
}

//getters and setters


public String getShape() {
return shape;
}

public void setShape(String shape) {
this.shape = shape;
}

public double getLength() {
return length;
}

public void setLength(double length) {
this.length = length;
}

public double getWidth() {
return width;
}

public void setWidth(double width) {
this.width = width;
}

public double getHeight() {
return height;
}

public void setHeight(double height) {
this.height = height;
}

//Method which calculates the area of the rectangle
public double area() {
area = length * width;
return area;
}

//Method which calculates the area of the volume
public double volume() {
volume = length * width * height;
return volume;
}

}

_________________

Test.java

import java.util.Scanner;

public class Test {

public static void main(String[] args) {

// Declaring variables
String shape;
double l, w, h;

/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);

// Getting the input entered by the user
System.out.print("Enter the Shape of the Swimming Pool :");
shape = sc.next();
System.out.print("Enter the Length :");
l = sc.nextDouble();
System.out.print("Enter the Width :");
w = sc.nextDouble();
System.out.print("Enter the Height :");
h = sc.nextDouble();

// Creating an Pool class object
Pool p = new Pool(shape, l, w, h);

/*
* This while loop continues to execute until the user enters a valid
* choice
*/
while (true) {
// displaying the menu
System.out.println(":: Menu ::");
System.out.println("1.Calculate Area ");
System.out.println("2.Calculate Volume ");

// getting the choice entered by the user
System.out.print("Enter choice ");
int choice = sc.nextInt();
// Based on the user choice the corresponding case will executed
switch (choice) {
case 1:
{

System.out.println("Shape :" + p.getShape());

System.out.println("Area of the Sminning Pool :" + p.area());

break;

}

case 2: {

System.out.println("Shape :" + p.getShape());

System.out.println("Volume of the Sminning Pool :" + p.volume());

break;

}
default:
{
System.out.println("** Invalid Choice **");
continue;
}
}
break;
}

}

}

__________________

Output:

Enter the Shape of the Swimming Pool :Rectangle
Enter the Length :3
Enter the Width :4
Enter the Height :5
:: Menu ::
1.Calculate Area
2.Calculate Volume
Enter choice 2
Shape :Rectangle
Volume of the Sminning Pool :60.0


_____________Could you rate me well.Plz .Thank You