Buoyancy is the ability of an object to float. Archimedes’ principle states that the buoyant force is equal to the weight of the fluid that is displaced by the submerged object. The buoyant force can be computed by:
Fb = V _ y Where Fb is the buoyant force, V is the volume of the submerged object, and y is the specific weight of the fluid. If Fb is greater than or equal to the weight of the object, then it will float, otherwise it will sink.
Write a program that inputs the weight (in pounds) and radius (in feet) of a sphere and outputs whether the sphere will sink or float in water.Use y = 62.4 lb/ft3 as the specific weight of water. The volume of a sphere is computed by (4/3)πr3.
#include <iostream>
using namespace std;
int main()
{
//Variables
double weight,radius,Fb;
//User input
cout<<"Enter weight(pounds):";
cin>>weight;
cout<<"Enter radius(feet): ";
cin>>radius;
//Compute buoyant force by using
//the volume of a sphere is computed by (4/3)πr3
Fb =62.4*((4 *3.14 * radius * radius * radius )/3);
//Print Output
//If Fb is greater than or equal to the weight
//of the object, then it will float, otherwise
//it will sink.
if(Fb>=weight)
cout<<"The sphere will float in water \n";
else cout<<"The sphere will sink in water \n";
}
Output of code:
Enter weight(pounds):100
Enter radius(feet): 5
The sphere will float in water