Programming can be used to assist users in completing
complex calculations very quickly. As seen in class practices, we
were able to calculate the area of geometric shapes, figure out the
number of calories in cookies, and even calculate a restaurant
bill.
For this assignment, you will take input from the user to provide
interactive messages and to solve the following word problem:
Engineers often need to convert between different types of units to
perform calculations that follow standard formulas. One very common
conversion involves converting distances. List the steps, by
writing pseudocode, which explains how you would ask the user to
provide the distance in miles and would display: 1) The distance in
kilometers, 2) the distance in feet, 3) the distance in
yards.
Example:
The program asks the user to provide their name and displays a
greeting message that explains its purpose. The program requests
the distance in miles. The user provides the number 158 for miles.
The program calculates and displays the results of 1) 254.28
kilometers, 2) 834240 feet, 3) 278080 yards
could you show me the programming using the pseudocode at idle? little confused
Take the input from user ( let say x )
Since 1 mile = 1.6 kilometers
1 mile = 5280 feet
1 mile = 1760 yard
So for mile to kilo multiply x by 1.6
for feet multiply x by 5280
for feet multiply x by 1760
Python code
distance_in_mile = int(input("Enter the distance in mile\n"))
dis_in_kilo = distance_in_mile * 1.6
dis_in_feet = distance_in_mile * 5280
dis_in_yard = distance_in_mile * 1760
print("Distance in kilometer is {}, distance in feet is {}, distance in yard is {}".format(dis_in_kilo,dis_in_feet,dis_in_yard))
Get Answers For Free
Most questions answered within 1 hours.