fork download
  1. //Conrad Taylor CSC5 Chapter 4, P. 220, #6
  2. //
  3. /*******************************************************************************
  4.  * Mass to newtons Converter
  5.  * _____________________________________________________________________________
  6.  * This program takes the height and width of two triangles, calculates the area
  7.  * and tells the user which rectangle is the largest or if they are the same.
  8.  * _____________________________________________________________________________
  9.  * INPUT
  10.  * weight
  11.  * mass
  12.  *
  13.  *
  14.  * OUTPUT
  15.  * too heavy
  16.  * too light
  17.  * neither
  18.  
  19.  ******************************************************************************/
  20.  
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main() {
  25.  
  26.  
  27.  
  28. float weight,
  29. mass;
  30.  
  31.  
  32. cout << endl;
  33. cout << "What is the object's mass: ";
  34. cin >> mass;
  35.  
  36.  
  37. weight = mass * 9.8;
  38.  
  39.  
  40. cout << "\nObject's weight = ";
  41. cout << weight << endl << endl;
  42.  
  43.  
  44. if (weight >= 1000)
  45. cout << "Too heavy.";
  46. else if (weight <= 10)
  47. cout << "Too light.";
  48. else
  49. cout << "Neither heavy or light.";
  50.  
  51. cout << endl << endl;
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
What is the object's mass: 
Object's weight = 4.49939e-40

Too light.