fork download
  1. // Nicolas Ruano CS1A Chapter 2, Pp. 82, #7
  2.  
  3. /*************************************************************************
  4. *
  5. *------------------------------------------------------------------------*
  6. * Output is when the procedure has been performed, giving the result of *
  7. * the ocean levels in the next few years *
  8. * -----------------------------------------------------------------------*
  9. * Input *
  10. * The calculation of the given years that will predict the ocean levels *
  11. * For the next upcoming years given *
  12. * *
  13. * Output *
  14. * The resolved claculation on the given milimeters calculated. *
  15. *************************************************************************/
  16.  
  17. #include <iostream>
  18. using namespace std;
  19.  
  20. int main() {
  21. // Rising rate per year in millimeters
  22. double riseRate = 1.5;
  23.  
  24. // Calculate future rises
  25. double riseIn5Years = riseRate * 5;
  26. double riseIn7Years = riseRate * 7;
  27. double riseIn10Years = riseRate * 10;
  28.  
  29. // Display results
  30. cout << "In 5 years, the ocean level will be " << riseIn5Years << " millimeters higher." << endl;
  31. cout << "In 7 years, the ocean level will be " << riseIn7Years << " millimeters higher." << endl;
  32. cout << "In 10 years, the ocean level will be " << riseIn10Years << " millimeters higher." << endl;
  33.  
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
In 5 years, the ocean level will be 7.5 millimeters higher.
In 7 years, the ocean level will be 10.5 millimeters higher.
In 10 years, the ocean level will be 15 millimeters higher.