fork download
  1. //Henry Hill CSC5 Chapter 4, P. 220, #6
  2. //
  3. /**************************************************************
  4.  * CALCULATE NEWTONS
  5.  * ____________________________________________________________
  6.  * This program ask the user for an object's mass, and then
  7.  * calculates and displays its weight in Newtons. If the
  8.  * object is over 1000 Newtons the program will indicate that
  9.  * it is too heavy and if it is under 10 Newtons the program
  10.  * will indicate that it is too light.
  11.  * ____________________________________________________________
  12.  * INPUT
  13.  * mass : Mass of the object
  14.  *
  15.  * OUTPUT
  16.  * weight : Weight in newtons
  17.  * ************************************************************/
  18. #include <iostream>
  19. #include <iomanip>
  20. using namespace std;
  21. int main()
  22. {
  23. float mass;
  24. float weight;
  25.  
  26. cout << "Please enter the mass of the object.\n";
  27. cin >> mass;
  28. weight = mass * 9.8;
  29. cout << "The object weight is ";
  30. cout << weight;
  31.  
  32. if (weight > 1000)
  33. cout << "The object is too heavy\n";
  34. else if (weight < 10)
  35. cout << "The object is too light\n";
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5484KB
stdin
100
stdout
Please enter the mass of the object.
The object weight is 980