fork download
  1. //Isabel Tejeda CSC5 Chapter 4, page 220, #6
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * DETERMINE AND CATERGORIZE WEIGHT
  6.  * _____________________________________________________________________________
  7.  * This program will ask for the input of an object's mass in kilograms and
  8.  * convert the mass to newtons. It will display the weight it newtons and then
  9.  * indicate whether the weight is too heavy or too light.
  10.  *
  11.  * Computation is based on the formula:
  12.  * weight = mass * 9.8
  13.  * _____________________________________________________________________________
  14.  * INPUT
  15.  * mass : The mass of an object in kilograms
  16.  *
  17.  * OUTPUT
  18.  * weight : The weight of an object in newtons
  19.  *
  20.  ******************************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26. float mass; // The mass of an object in kilograms
  27. float weight; // The weight of an object in newtons
  28. //
  29. // Initialize Program Varaibles
  30. cout << "Enter the object's mass in kilograms: "<< endl;
  31. cin >> mass;
  32. //
  33. // Calculate the Weight of the object in newtons
  34. weight = mass * 9.8;
  35. //
  36. // Output Weight
  37. cout << "The object's weight is " << weight << " newtons." << endl;
  38. //
  39. // Determine if the object is too heavy/too light
  40. if (weight > 1000)
  41. cout << "The object's weight is too heavy.";
  42. else if (weight < 10)
  43. cout << "The object's weight is too light.";
  44. else
  45. cout << "The object's weigh is acceptable.";
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5436KB
stdin
1000
stdout
Enter the object's mass in kilograms: 
The object's weight is 9800 newtons.
The object's weight is too heavy.