Question: Can you help me with this program please? Write the code for the interface (NOT the java keyword) and implementation of a class that models

Can you help me with this program please?

Write the code for the interface (NOT the java keyword) and implementation of a class that models a BeachBall, then code a simple application program to use this class.

(a) Write the BeachBall class:

A BeachBall has the following properties:

a diameter and a label.

Provide the following methods:

(i) a constructor that gets initial values for each property from the parameter list.

(ii) accessors for each of the properties (one per property),

(iii) a mutator for the diameter only.

(iv) a function to compute the volume of the beach ball.

(v) a function to compute the "diametric platipus" between this beach ball

and another beach ball.

(vi) a toString method that returns a summary of the properties.

The formula for the volume of a beach ball is as follows: v = (4/3)(d/2)3

where

v = volume (cubic inches)

d = diameter (inches)

= PI (3.14159...)

The formula for the "diametric platipus" between two beach balls is:

dp = ((3a)2 - (3b)2)

where

dp = diametric platipus

a = diameter of one beach ball (inches)

b = diameter of another beach ball (inches)

(b) Code an application:

Make a class (TestBeachBall) that contains a main program to do the following:

(i) Define an array of three beach balls

(ii) Initialize the elements of the array to refer to the following:

a beach ball with a 6-inch diameter labeled 'Fred',

a 9-inch beach ball labeled 'Disneyland',

a 12-inch beach ball labeled 'Monte Carlo',

  1. Compute the total volume (add them up) of the three beach balls (using their

member functions) and display the result. (To compute the total, write code that

would still work for 1000 beach balls, or any number.)

(iv) Compute the diametric platipus between the first and last beach balls,

and display the result.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!