fork download
  1. //OrinTill Qimid CS1A Chapter 3, P. 145, 9
  2. //
  3. /**************************************************************
  4.  * Compute Given weight
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will Calcuate the amount of mass in newtons when given the weight in kg
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * Object : the mass of the object in kgs
  11.  * OUTPUT
  12.  * weight : the of the weight of the object in newtons.
  13.  **************************************************************/
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cmath>
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. float object,
  22. weight;
  23. cout <<"Please enter the mass you want to calculate in kg"<<endl;
  24. cin >> object;
  25. weight = object * 9.8;
  26.  
  27.  
  28. if (weight<10)
  29. {
  30. cout<<"Sorry the object is too light"<<endl;
  31.  
  32. }
  33. else if (weight>1000)
  34. {
  35. cout <<"The object is heavy"<<endl;
  36. }
  37. else
  38. cout <<"This is your weight in newtons " << weight << endl;
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 5292KB
stdin
1
stdout
Please enter the mass you want to calculate in kg
Sorry the object is too light