Question: Learn to write do - while loops. Assignment: In developing an algorithm for a new fitness app, you're tasked with calculating the cumulative elevation gain

Learn to write do-while loops.
Assignment: In developing an algorithm for a new fitness app, you're tasked with calculating the cumulative elevation gain for a 50-step stair-climbing challenge. Each step increases in height exponentially, starting from 1 meter for the first step and doubling the height increase for each subsequent step.
Given long variables totalElevation and step that have already been declared, use a do-while loop to calculate the total elevation gain over 50 steps, with each step's elevation gain being twice the previous step's gain (starting from 1 meter for the first step). Store this cumulative elevation in totalElevation.
For example, the elevation gain sequence will start 1,2,4,8, etc., doubling each time.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!