In: Computer Science
Your software company was invited to provide a proposal for a company in Australia. You currently have the cost in US dollars and need to convert the prices to the Australian dollar. Write a 2-part program using Ruby, Java®, or Python. Part 1: Write a function to gather the following costs from the user: Travel Cost: $9,800 Hotel Cost: $3,500 Rental Car Cost: $1,600 Labor Cost: $15,500 Part 2: Write a function to convert the costs from United States dollar (USD) to Australian dollar (AUD). Note: Look up the current USD to AUD exchange rate to use in your function. Test the program 3 times by providing different costs in USD. Provide the code and take a screenshot of the output, then paste the screenshot(s) into a Microsoft® Word document. Write a half-page response in the same Microsoft® Word document to address the following: Provide a manual for the user explaining how to use the program. Explain what type of user input validations you should have. What happens if the user enters a negative number? What happens if the user puts a $ in the input?
Python Program:
def getInput(st):
""" Function that reads the input from user """
try:
# Reading costs from user
cost = float(input("Enter " + st +
" : "))
# Checking for negative
amount
if cost < 0:
print("\n Please
enter positive amount.. ")
getInput(st)
# Returning cost
return cost
except:
# Printing error message
print("\nError: Please input
positive amount with out $ symbol")
getInput(st)
def convert_USD_AUD(USD):
""" Conversion from USD to AUD """
# Conversion Factor
# 1 USD = 1.47923 AUD
return (USD * 1.47923)
def main():
""" Python program that converts USD to AUD """
# Reading costs from user
travelCost = getInput("Travel Cost")
hotelCost = getInput("Hotel Cost")
rentalCarCost = getInput("Rental Car Cost")
laborCost = getInput("Labor cost")
# Converting Cost from USD to AUD
a_travelCost = convert_USD_AUD(travelCost)
a_hotelCost = convert_USD_AUD(hotelCost)
a_rentalCarCost = convert_USD_AUD(rentalCarCost)
a_laborCost = convert_USD_AUD(laborCost)
# Printing costs in AUD
print("\n\n Costs in AUD: \n")
print("\n Travel Cost: %.2f"%(a_travelCost))
print("\n Hotel Cost: %.2f"%(a_hotelCost))
print("\n Rental Car Cost:
%.2f"%(a_rentalCarCost))
print("\n Labor Cost: %.2f \n\n"%( a_laborCost))
# Calling main function
main()
______________________________________________________________________________________________________
Sample Run:
___________________________________________________________________________________________________
If a negative number is entered, user will be prompted again...
If an amount is entered with dollar symbol, user will be prompted again...