Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Rectangle class that has two instance variables: length and width of the rectangle (both are floating-point numbers). The class should have two constructors:

Write a Rectangle class that has two instance variables: length and width of the rectangle (both are floating-point numbers). The class should have two constructors: one with two parameters for the two instance variables, and a no-argument constructor (set both instance variables to zero). Include the following:

Three accessor methods: one to return the length, one to return the width and one called computeArea that returns the area of the rectangle.

Two mutator methods: one to set the value of the length and the other to set the value of the width.

Then write another class called Cuboid that is derived from Rectangle and has an additional instance variable: height of the cuboid. This class also has two constructors: one with three parameters for the three instance variables, and a no-argument constructor (set all instance variables to zero). The class also includes:

Two accessor method: one that returns the height of the cuboid and one called computeVolume that returns the volume of the cuboid.

A mutator method that set the value of the heigth.

Override the computeArea to return the area of the cuboid.

Finally, write a driver program that tests the two classes and all the methods in both classes.

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago