Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an application that prompts the user for a total of purchases, and then c

ID: 3778950 • Letter: C

Question

Create an application that prompts the user for a total of purchases, and then converts the total to a foreign currency. The program must run all test cases of purchases in one execution. Use a sentinel value to terminate the program. Output screenshot must include the input values & their converted values.

Rules:

Purchase must be greater than zero. If zero or less, reprompt for that purchase again.

Currency conversions:

$1 USD = 82.66 Japanese Yen

$1 USD = .994 Canadian $

$1 USD = 0.77 Euro

$1 USD = 0.625 British Pound                   

$1 USD = 2.1338 Brazilian Real

$ 1 USD = 6.2686 Chinese Yuan

Run your application with the following data and save the screenshot of inputs and outputs to submit.

Purchase: Convert to:

$ 251.95                         Real

-5.88 replace with $15.88       Yuan

$ 7,206.73 Euro

$ 1,634.72 Yen

$ 599.99 Pound

Explanation / Answer

def convert_currency():
    amount = input("Enter the amount of purchase: ")
    while amount<0:
        print "Enter a positive number"
        amount = input("Enter the amount of purchase: ")
    convert = raw_input("Enter the currency in which you want to convert: ")
    if convert.lower() == "yen":
        camount = 82.66*amount
    elif convert.lower() == "canadian dollars":
        camount = 0.994*amount
    elif convert.lower() == "euro":
        camount = 0.77*amount
    elif convert.lower() == "pound":
        camount = 0.625*amount
    elif convert.lower() == "real":
        camount = 2.1338*amount
    elif convert.lower() == "yuan":
        camount = 6.2686*amount
    else:
        print "This is not a valid currency"

    return str(amount) + " dollars in " + convert + " is " + str(camount)

print convert_currency()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote