fork download
  1. //Adhira B CS1A ch5
  2. /**************************************************************************
  3.  *
  4.  * COMPUTE OCEAN RISE IN MM
  5.  * ________________________________________________________________________
  6.  * program computes how much the ocean will rise through rate and years
  7.  *
  8.  * INPUT
  9.  * Rate : how much the ocean currently rises a year mm
  10.  * Time : years needed to be calculated
  11.  *
  12.  * OUTPUT
  13.  * how much mm ocean will rise
  14.  *
  15.  *************************************************************************/
  16. #include <iostream>
  17. using namespace std;
  18.  
  19. int main() {
  20. float Rate = 1.5; // initialize how much ocean rises a year
  21. int Time;
  22. float Final;
  23.  
  24.  
  25. for(Time = 1; Time < 26; Time++)
  26. {
  27. Final = (Rate * Time);
  28. cout << "in " << Time << " years, the water would have risen " << Final << " mm." << endl;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
in 1 years, the water would have risen 1.5 mm.
in 2 years, the water would have risen 3 mm.
in 3 years, the water would have risen 4.5 mm.
in 4 years, the water would have risen 6 mm.
in 5 years, the water would have risen 7.5 mm.
in 6 years, the water would have risen 9 mm.
in 7 years, the water would have risen 10.5 mm.
in 8 years, the water would have risen 12 mm.
in 9 years, the water would have risen 13.5 mm.
in 10 years, the water would have risen 15 mm.
in 11 years, the water would have risen 16.5 mm.
in 12 years, the water would have risen 18 mm.
in 13 years, the water would have risen 19.5 mm.
in 14 years, the water would have risen 21 mm.
in 15 years, the water would have risen 22.5 mm.
in 16 years, the water would have risen 24 mm.
in 17 years, the water would have risen 25.5 mm.
in 18 years, the water would have risen 27 mm.
in 19 years, the water would have risen 28.5 mm.
in 20 years, the water would have risen 30 mm.
in 21 years, the water would have risen 31.5 mm.
in 22 years, the water would have risen 33 mm.
in 23 years, the water would have risen 34.5 mm.
in 24 years, the water would have risen 36 mm.
in 25 years, the water would have risen 37.5 mm.