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.".
I'm not even sure where to start with this one. lol
Any help please?
int main ()
float y = 62.4;//Constant given, float value
float w; //Variable weight, float value
float r; //Variable radius, float value
double V; //Variable Volume, double value
double Fb; //Variable Buoyant Force, double value
char answer; // Variable answer, char
do //"Do" since you will be doing this loop at least once
cout<< "Please enter weight of the object in lbs and press enter: " <<endl;//Prompts user to enter weight
cin>> w; // User enters weight
cout<< "Please enter radius of the object in feet and press enter: " << endl;//Prompts user to enter radius
cin >> r ; // User enters radius
V=(4/3)*(M_PI)*(pow(r,3)); //Calculates Volume
Fb = (V)*(y); //Calculates Buoyant Force
if (Fb >= w)//Determines if Fb is greater than or equal to w
cout << "This Sphere will float! :) " << endl; //Prints that the sphere floats
else //If Fb < w
cout << "This Sphere will sink! :( " << endl; // Prints that the sphere sinks
cout << "Calculate another buoyancy? (y/n) " << endl; //Asks if the user wants to calculate another buoyancy
cin >> answer; //User enters y/n or Y/N
} while ((answer == 'y' || answer == 'Y'));//Goes back to beginning of loop if user enters 'y' or 'Y'
cout << "End of Testing!" << endl; //Prints end of testing