Lab 4: Using Functions
Due Wednesday, September 20
Download the partial program lab4start.cpp. In main, it makes a number of calls to functions that don't yet exist! Write the functions to finish the program.
- cube, takes one parameter of type double, returns the cube of that number (raises it to the third power)
- area_of_right_triangle, takes two parameters of type double, calculates the area of a right triangle (neither parameter is the hypotenuse)
- volume_of_cone, takes two float parameters, figures out the volume of a cone with that radius (first parameter) and height (second parameter)
- weight_of_water_room, takes three parameters of type double, which are the dimensions of a room. Returns the weight of water that would fit in that room. Assume input is in feet, and output in pounds.
- rabbit_house, takes two parameters of type float and one parameter of type char (which can be 'n, 'd', or 'l'. This function will allow you to determine how many rabbits your house can accommodate. The first parameter is the number of square feet of area, the second is the average weight of the rabbits that are to be kept in that house, and the last parameter is the population density. Normal density for caged rabbits is 0.75 square feet per pound of rabbit. "dense" is 0.6, and "light" is 1.0. Convert the answer to an integer before returning it from the function. The return type should be int.
- number_string, takes a single integer parameter which is not negative and is less than 10 (you don't have to enforce these constraints). Returns a string, which is the spelled-out version of the number. So number_string(5) should return "five", and number_string(0) should return "zero".