Homework 9 Solution

$30.00 $24.00

Setup: Add a new cpp to the hw9.sln and copy the code end of this document. Problem: There are two boxes. You would like to know how much volume would not be displaced if you placed the smaller box inside of the larger box. To accomplish this, you decide to write a recursive function that…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)

Setup:

Add a new cpp to the hw9.sln and copy the code end of this document.

Problem:

There are two boxes. You would like to know how much volume would not be displaced if you placed the smaller box inside of the larger box. To accomplish this, you decide to write a recursive function that will compute the volume of a box. You want to make this program easy to use and decide to prompt the user for the height of the larger box along with how many square units are on the bottom of this box. You then prompt for the height and square units for the smaller box. Once you have both volumes, you can compute how much volume would not be displaced.

Height = h

Base Square Units = b * a

Vol = volume( h, baseSu );

  • example

  • a box with a height of 4 and a baseSU of 18 (3*6) Vol = volume( h, baseSU );

Requirements:

You must right a recursive function that will compute the volume of the box given the height and the number of square units at the base. This function must return the number of cubic units for the box.

If you find yourself writing a loop, you are not letting recursion do the work. The recursive calls form the loop.

You must create 5 more test functions that you add to the “Volume” TEST_CASE. Try and get the wrong answers. Place a comment above the CHECK stating why you are using this.

To get credit for this, you must have 5 valid test cases and pass the include tests and your own.

Examples:

Data for largest box:

Enter the area of the base: 15

Enter the height: 5

Data for the smallest box:

Enter the area of the base: 21

Enter the height: 2

The smaller box could displace all but 33 cubic units of the larger box.

Catch Test Cases:

Develop 5 test cases in the addition to the once provided. Try and come up with numbers that will test the volume function. Assume all values will be positive and under 1000.

Homework 9 Solution
$30.00 $24.00