fork(1) download
  1. //Nicolas Ruano CS1A Pp. 294 2
  2. /******************************************************************************
  3.  * PREDICING OCEAN LEVELS
  4.  *
  5.  * In this program, we go through calculations of ocean levels and what will
  6.  * it estimate for 25 years.
  7.  *
  8.  *****************************************************************************
  9.  * INPUT:
  10.  * the number of rising will be 1.5, which we will rewrite it as risePerYear
  11.  *
  12.  * The, we calculate the input what the sea level will be in 25 years
  13.  *
  14.  * OUTPUT
  15.  * Displays a list of years of what the sea levels will be at in 25 years
  16. ******************************************************************************/
  17. #include <iostream>
  18. #include <iomanip> // for formatting output
  19. using namespace std;
  20.  
  21. int main() {
  22. const double risePerYear = 1.5; // millimeters per year
  23.  
  24. cout << "Year\tRise (mm)" << endl;
  25. cout << "----------------" << endl;
  26.  
  27. // Loop through 25 years
  28. for (int year = 1; year <= 25; year++) { //We calculate the input
  29. double rise = year * risePerYear;
  30. cout << setw(2) << year << "\t" << fixed << setprecision(1) << rise << endl;
  31. }
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Year	Rise (mm)
----------------
 1	1.5
 2	3.0
 3	4.5
 4	6.0
 5	7.5
 6	9.0
 7	10.5
 8	12.0
 9	13.5
10	15.0
11	16.5
12	18.0
13	19.5
14	21.0
15	22.5
16	24.0
17	25.5
18	27.0
19	28.5
20	30.0
21	31.5
22	33.0
23	34.5
24	36.0
25	37.5