
We shape clay into a pot, but it is the
emptiness inside
C++ that hold what we want. – Tao Te Ching
K. Dzwonkiewicz
This Program must be done with two functions.
Two years ago a huge oil tanker transporting oil from Kuwait to the east coast of the USA sanl off the south western tip of Africa. Hips will sometimes travel the extra 9000 miles to avoid paying the high tarrifs charged to pass trough the Suez Canal. Unfortunately the tip of Africa in the area called the Cape of Good Hope has some of the worst storms on Earth…many ships will sink. The shi “The Crude Dude” encountered a terrible storm with waves exceeding 150 feet. It developed a small crack that widened with time (the ship eventually sank).
As oil leaked from the crack an expanding oil slick developed around the boat’s hull. The radius of the slick was 250 feet per hour ( r = 205 * time ) for the first four hours. [0, 4]
After four hours up to and including 6 hours the radius was 350 feet per hour (r= 4 * 250 + (time -4) * 350). (4, 6]
After 6 hours the radius expanded a by 450 feet per hour. (6, ~)
Write a C++ program to determine the area of the oil slick if given time in decimal hours.
Ø Have in your main the cin of time.
Ø Call a function, call it Get_area, where you send in the parameter of time and return the value of area of the slick.
Ø In the function Get_area, call a second function, call it Get_radius, where you send in time and return radius.
Ø In Get_radius, you must check the time value to get the correct calculated radius value (as above).
(in mathematics, this is a composite function A(t(t)) = Pi x (250)^2) )
Hint: In your main… area = Get_area(time)
In Get_area… radius = Get_radius(ftime);
return … (area formula will go here)
In Get_radius… have some if statements as given up top.
Sample run… (pi = 3.1415)
|
Please enter the time in decimal hours: 6.5 Radius is: 1925 ft Area is: 11641220 sq. ft. |
“We are more curious about the things we see in dreams than
about things we see when awake.”
Diogenes