If she floats then she is not a witch like we thought Continuing my C++ saga, this is the third project for my CS1 class:


  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
  
  $$ F_b = V \cdot y $$
  
  where \$ F_b \$ is the buoyant force. \$ V \$ is the volume of the
  submerged object, and \$ y \$ is the specific weight of the fluid.  If
  \$ F_b \$ 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 \dfrac{\text{lb}}{\text{ft}^3} \$ as the
  specific weight of water.  The volume of a sphere is computed by \$ \left( \dfrac{4}{3} \right) \pi r^3\$.


Additionally, I must have a loop in this program that allows the user to run it as many times as they want to. I have to ask the user each time whether they want to continue. 

It is also supposed to be fully commented, which I think I have done within reason.

buoyancy.cpp:

/**
 * @file buoyancy.cpp
 * @brief Calculates if a sphere will sink or float in water given the weight and radius
 * @author syb0rg
 * @date 9/12/14
 */

#include &lt;iostream&gt;
#include &lt;limits&gt;
#include &lt;math.h&gt;

/**
 * Sphere
 * @var weight The weight of the sphere
 * @var radius The height of the sphere
 */
struct Sphere
{
    double weight = 0;
    double radius = 0;
};

/**
 * Resets the command line so we can input data again, and signals user to re-enter proper data
 */
void resetConsole()
{
    std::cin.clear(); // clear the error flag that was set so that future I/O operations will work correctly
    std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n'); // skips to the next newline
    std::cout &lt;&lt; "Invalid input.  Please enter a positive number: ";
}

int main()
{
    constexpr double waterBuoyancy = 62.4;
    Sphere obj;
    char again = '\0';
    do
    {
        // get input for height, re-read input if not a positive number
        std::cout &lt;&lt; "Enter the weight in pounds: ";
        while(!(std::cin &gt;&gt; obj.weight) || obj.weight &lt; 0) resetConsole();

        // get input for radius, re-read input if not a positive number
        std::cout &lt;&lt; "Enter the radius in inches: ";
        while(!(std::cin &gt;&gt; obj.radius) || obj.radius &lt; 0) resetConsole();

        double volume = ((4/3) * M_PI * pow(obj.radius, 3));
        double bouyantForce = volume * waterBuoyancy;

        if (obj.weight &lt;= bouyantForce) std::cout &lt;&lt; "The object will float." &lt;&lt; std::endl;
        else std::cout &lt;&lt; "The object will sink." &lt;&lt; std::endl;

        std::cout &lt;&lt; "Run the program again (y/N): ";
        std::cin.get();  // absorb newline character from previous input
        std::cin.get(again);
        again = tolower(again);
        if ('\n' == again) again = 'n';
    } while (again == 'y');
}
There are several small things that you can improve:


double weight = 0; works fine, but double weight = 0.0; would be more pedantic since weight is a double.
By the way, the following line is a good example to illustrate the benefits of literals pedantry:

double volume = ((4/3) * M_PI * pow(obj.radius, 3));


Here, 4/3 performs an integer division and not a floating point one; that expression will yield 1 instead of 1.333333333 (I doubt that you want it to yield 1). You should change it to 4.0/3.0 to get the desired result.
That said, there is another problem with the aforementioned line: M_PI is not standard C++. It is not standard C either. It is a standard POSIX addition to &lt;math.h&gt;. You should rewrite your own constants or use Boost ones for examples if you want your code to be portable.
Speaking of &lt;math.h&gt;... You are using C++, therefore you should use the C++ standard library headers too and not the C ones:

#include &lt;cmath&gt;

And you notably forgot to include the header &lt;ctype.h&gt; for std::tolower.
That said, it is good practice in C++ to fully qualify the names of the functions from the standard library: you should write std::tolower (and thus actually include &lt;cctype&gt; instead  of &lt;ctype.h&gt;). It's not really longer and it may help to prevent name clashes (I doubt that you will have problems with tolower, but it can be worse with some more common names).