All pastes #637767 Raw Edit

mass - weight program

public cpp v1 · immutable
#637767 ·published 2007-07-29 05:49 UTC
rendered paste body
int main(){    // Declare variables    double mass;    double weight;    weight = (mass * 9.8);        // Get mass from user    cout << "Please input the object's mass." << endl;    cin >> mass;        // Make sure the variable is between 10 N and 1,000 N    if (mass < 10)       {               cout << "The object is too light to be weighed." << endl;               cout << "Please input a greater mass and try again." << endl;       }        else if(mass > 1000)         {                   cout << "The object is too heavy to be weighed." << endl;                   cout << "Please input a smaller mass and try again." << endl;         }             else        {                   cout << setprecision(2) << showpoint << fixed;                   cout << "The object's weight is " << weight << " Newtons.";         }            // Sleep timer    Sleep(60000);    return 0;} // For some reason, this program displays the weight as 0.00 no matter what values I input. // When I replace weight in line 36 with (mass * 98) it works.