In: Computer Science
Under normal conditions, commercial aircraft generally rise at
about 1,000 to 2,000
feet per minute (this is called the rate of climb) after take-off,
until they reach a
cruising altitude of 35,000 feet. Design the logic for a program
that allows the user to
enter the rate of climb as input, and then for every minute after
take-off until the
aircraft has reached cruising altitude, outputs the minute number,
and the height of the
plane after that minute. After that the program must output the
number of minutes that
have elapsed since take off, and the height at which the plane is
cruising (this may not
be exactly 35,000 feet).
Apply following logic:
Ask the climb rate from user and store it in variable
climb_rate
set variable as below
height=0
minute=0
Run a conditional Loop as below
while height < 35000:
height = height + climb_rate
minute = minute +1
print (minute, height)
end while
Print (minute and height) // this will print the required minute to
climb 35000 feet.
Here is a short program in python.
# initialize variables
height = 0
minute = 0
climb_rate = int(input("enter rate of climb(in feet):"))
print("Minute Height\n")
while height < 35000:
height = height + climb_rate
minute = minute + 1
print("%d \t %d"%(minute, height))
print("Time needed to reach heght %d is %d
minute"%(height,minute))
Also the image version and program outut is given