Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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/cubic feet as the specific weight of water. The volume of a sphere is computed by (4/3)(r cubed).

I have attached my code below. The output tells me there is a logic error, I am just not sure where. Any advice is helpful! Thanks!

#include

#include

using namespace std;

int main(){

double buoyantForce = 0;

double volume = 0;

float specificWeightWater = 62.4;

float radiusSphere = 0;

float weightSphere = 0;

double PI = M_PI;

cout << "Enter the radius of the sphere, in feet: ";

cin >> radiusSphere;

cout << "Enter the weight of the sphere, in pounds: ";

cin >> weightSphere;

volume = (4/3)*(PI)*(radiusSphere)*(radiusSphere)*(radiusSphere);

buoyantForce = volume * specificWeightWater;

if (buoyantForce >= weightSphere){

cout <<"The sphere will float."<< endl;

}

else{

cout << "The sphere will sink."<< endl;

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

I am encouraged to offer opinions/suggestions.

Answered: 1 week ago