aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk1/hw1_directory/strap012_1A.cpp
blob: abef32d0b75502e4ac80dea00593874fa0c68804 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
  float r; //Radius
  float h; //Height
  
  cout << "Input the radius of the sphere: ";
   cin >> r;
  cout << "Input the height of the fluid: ";
   cin >> h;
  
  cout << fixed << setprecision(2) //Set rounding to 2 decimal places
    << "Volume of the entire tank: " << ((4.0/3) * M_PI * pow(r, 3)) << endl
    << "Surface area of the entire tank: " << (4 * M_PI * pow(r, 2)) << endl
    << "Volume of the fluid: " << (1.0/3) * (M_PI * pow(h, 2) * (3 * r - h )) << endl
    << "Surface area covered by the fluid: " << (2 * M_PI * r * h) << endl << endl;
}