A frog needs to jump to reach the swamp. The total distance it needs to cover is given by the user. The jump distance that can be covered by the frog in each jump is also given. After each jump, the...


What to modify on this code to make it working





#include
using namespace std;
int
main ()
{
  int jumps, distance, loss = 1, counter,total_distance=0;
  cout < "enter="" the="" distance:="">
  cin >> distance;
  cout < "how="" much="" it="" can="" jump:="">
  cin >> jumps;
  while (counter <>
    {
      jumps -= 1;
      total_distance += jumps;
      counter++;
    }
  cout < "the="" distance:=""><>
  return 0;
}


A frog needs to jump to reach the swamp. The total distance it needs to cover is<br>given by the user. The jump distance that can be covered by the frog in each jump is<br>also given. After each jump, the jump distance is decreased by 1 because it loses<br>energy. Write a program to calculate and print the distance covered by the frog after<br>each jump and the total jumps needed to cover the total distance. See the given<br>sample of input/output. (hint: use while loop)<br>Sample Input/Output:<br>How much distance to cover: 53<br>How much distance to cover: 60<br>How much it can jump: 10<br>How much it can jump: 10<br>After jump #1 distance covered<br>After jump #2 distance covered<br>10<br>After jump #1 distance covered<br>After jump #2 distance covered<br>After jump #3 distance covered<br>After jump #4 distance covered = 34<br>After jump #5 distance covered<br>After jump #6 distance covered<br>After jump #7 distance covered = 49<br>After jump #8 distance covered = 52<br>After jump #9 distance covered = 54<br>After jump #10 distance covered =<br>The frog lost the energy before reaching the swamp<br>10<br>%3D<br>19<br>19<br>27<br>After jump #3 distance covered<br>After jump #4 distance covered =<br>After jump #5 distance covered =<br>After jump #6 distance covered<br>After jump #7 distance covered<br>After jump #8 distance covered<br>After jump #9 distance covered<br>The frog made it to the swamp after 9 steps<br>27<br>34<br>40<br>40<br>45<br>45<br>%3D<br>49<br>52<br>55<br>54<br>||D<br>|| || | |||<br>

Extracted text: A frog needs to jump to reach the swamp. The total distance it needs to cover is given by the user. The jump distance that can be covered by the frog in each jump is also given. After each jump, the jump distance is decreased by 1 because it loses energy. Write a program to calculate and print the distance covered by the frog after each jump and the total jumps needed to cover the total distance. See the given sample of input/output. (hint: use while loop) Sample Input/Output: How much distance to cover: 53 How much distance to cover: 60 How much it can jump: 10 How much it can jump: 10 After jump #1 distance covered After jump #2 distance covered 10 After jump #1 distance covered After jump #2 distance covered After jump #3 distance covered After jump #4 distance covered = 34 After jump #5 distance covered After jump #6 distance covered After jump #7 distance covered = 49 After jump #8 distance covered = 52 After jump #9 distance covered = 54 After jump #10 distance covered = The frog lost the energy before reaching the swamp 10 %3D 19 19 27 After jump #3 distance covered After jump #4 distance covered = After jump #5 distance covered = After jump #6 distance covered After jump #7 distance covered After jump #8 distance covered After jump #9 distance covered The frog made it to the swamp after 9 steps 27 34 40 40 45 45 %3D 49 52 55 54 ||D || || | |||

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here