fork download
  1. //Andres Guzman CSC5 Chapter 4, P. 220, #6
  2. //
  3. /**************************************************************
  4. *
  5. * CALCULATE THE WEIGHT
  6. * ____________________________________________________________
  7. * This program will calculate the weight of an object.
  8. *
  9. * Computation is based on the formula:
  10. * Weight = mass x 9.8
  11. * ____________________________________________________________
  12. * INPUT
  13. * mass = The mass of the object
  14. * OUTPUT
  15. * weight = the total newtons of the object
  16. *
  17. **************************************************************/
  18. #include <iostream>
  19. using namespace std;
  20.  
  21. int main()
  22. {
  23. float mass;
  24. float weight;
  25. //
  26. //
  27. cout << "Object's Mass: ";
  28. cin >> mass;
  29. //
  30. //
  31. weight = mass * 9.8;
  32. //
  33. //
  34. cout << "\nObject Weight: " << weight << endl;
  35. if (weight > 1000)
  36. cout << "The object is too heavy";
  37. if (weight < 10)
  38. cout << "The object is too light";
  39.  
  40. }
  41.  
Success #stdin #stdout 0.01s 5308KB
stdin
1000
stdout
Object's Mass: 
Object Weight: 9800
The object is too heavy