What to modify on this code to make it working#include using namespace std;intmain (){ 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;}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 || || | |||
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 || || | |||
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here