Answer to Question #183022 in C++ for Vincenzo Santoro

Question #183022

An oil slick occurs when an underwater refinery pipe ruptures, pumping oil into the water. The spilled oil sits on top of the water and causes a natural disaster. For simplicity, suppose that the oil sits on top of the water in the form of a circle.

Instructions

Write a program that prompts the user to enter the rate at which the ruptured pipe pumps oil (in gallons) per minute, the thickness of the oil on top of the water, and the number of days for which the area is covered by the spilled oil. The program outputs the spilled area (in kilometers) and the volume of oil (in gallons) on top of the water after each day.

Format your output with setprecision(8) to ensure the proper number of decimals for testing!



1
Expert's answer
2021-05-01T14:11:46-0400
#include <iostream>
#include <iomanip> 


int main()
{
    double oilSpeed{ 0 };
    double thicknessOil{ 0 };
    double timeDay{ 0 };
    double volumeOil{ 0 };
    double areaSplit{ 0 };
    std::cout << "Enter the speed of the oil in the pipe, gallons per minute: ";
    std::cin >> oilSpeed;
    std::cout << "Enter the number of days: ";
    std::cin >> timeDay;
    std::cout << "Enter the thickness of the oil slick in millimeters: ";
    std::cin >> thicknessOil;
    std::cout << std::setprecision(std::numeric_limits<float>::max_digits10);


    for (int i = 1; i <= timeDay; i++)
    {
        volumeOil = 1440.0 * i * oilSpeed;
        areaSplit = (0.00378541 * volumeOil) / (thicknessOil *1000);


        std::cout << "After " << i << " days the volume of oil will be: "<<std::setprecision(8) << volumeOil << " gallons."<<std::endl;
        std::cout << "Oil slick area : " << std::setprecision(8)<< areaSplit << " square kilometers" << std::endl;
    }


    system("pause");
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS