In: Computer Science
C++ program
Dairy Farm decided to ship milk in containers in the form of cubes rather than cylinders.
Write a program that prompts the user to input:
The program then outputs:
You may assume that the value of π = 3.141593.
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
int main()
{
std::cout << std::fixed;
std::cout << std::setprecision(2);
float radius,height;
float volume;
//The radius of the base of a cylindrical
container
cout<<"Enter the radius of the base of a cylindrical
container\t:";
cin>>radius;
//The height of the cylindrical container
cout<<"Enter the height of the cylindrical
container\t:";
cin>>height;
volume=(3.141593*radius*radius*height);
//The side of the cube with the same volume as the
cylindrical container with a precision of 2 decimal places.
cout<<"The side of the cube with the same volume as the
cylindrical container\t:"<< cbrt(volume) << endl;
return 0;
}