程序代写代做代考 Programming Exercise 3-1

Programming Exercise 3-1

Programming Exercise 5-1

# Global constant for conversion

KILOMETERS_TO_MILES = 0.6214

# main def

def main():

# Local variables

mykilometers = 0.0 # Variable to hold the distance in kilometers

# Get distance in kilometers

mykilometers = float(input(“Enter the distance in kilometers: “))

# Print miles

showMiles(mykilometers)

# The showMiles function accepts kilometers as an argument

# and prints the equivalent miles.

def showMiles(kilometers):

#Declare local variables

miles = 0.0

miles = kilometers * KILOMETERS_TO_MILES

print (“The conversion of”, format(kilometers, ‘.2f’), “kilometers”)

print (“to miles is”, format(miles, ‘.2f’), “miles.”)

# Call the main function.

main()

main()

getKilometers

(distanceKilometers)

showMiles

(distanceKilometers)

End

Declare

distanceKilometers

getKilometers

(Ref kilometers)

Return

Display “Enter

the distance in

kilometers.”

Input

kilometers

showMiles

(kilometers)

Return

Set miles =

kilometers *

KILOMETERS

_TO_MILES

Display

“The conversion of “,

kilometers, “ to miles

is “, miles, “ miles.”

Declare

miles

Global Constant Real

KILOMETERS_TO_MILES