Can someone help me correct the C++ code? Thank you! Chapter 2 Exercise 6 BUOYAN
ID: 3664868 • Letter: C
Question
Can someone help me correct the C++ code? Thank you!
Chapter 2 Exercise 6
BUOYANCY
Buoyancy is the ability of an object to float. Archimede's 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:
buoyant force = (object volume) times (specific gravity of the fluid)
If the buoyant force 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 62.4 lb/cubic foot as the specific weight of water. The volume of a sphere is computed by (4/3) times the radius cubed.
INPUT and PROMPTS. The program uses this prompt ""Input weight of the sphere in pounds." for the first number it reads in, the weight of the sphere. The program uses this prompt "Input radius of the sphere in feet." for the second number it reads in, the radius of the sphere. Do not print out these numbers as they are read in
OUTPUT . The program either prints out "The sphere will float in water." or "The sphere will sink in water.".
#include<iostream>
using namespace std;
int main()
{
double weight,radius;
cout <<"Input weight of the sphere in pounds.";
cin >> weight;
cout <<"Input radius of the sphere in feet.";
cin >> radius;
double Volume = (4.0/3.0)*3.14159*radius*radius*radius;
double Fb = Volume * 62.4;
// 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.
if(Fb >= weight)
cout << "The sphere will float in water." << endl;
else
cout <<"The sphere will sink in water." << endl;
}
Explanation / Answer
#include #include #include using namespace std; double sphere_volume (double); double buoy_force (double,double); int main () { double rad,volume,force,buoyancy; double weight; double water = 62.4; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.