#!/usr/bin/python3
import sys

# Program: milesPerGallon01.py
# Objective: Calculate the milage for a vehicle using the fill-up data.
# Revisions
#           Check for division by zero error
# Edward Bigos


def getFloatValue(message):
    try:
        fValue = float(input(message + ": "))
    except ValueError as error:
        print("Error: ", error)
        print("You have entered an invalid value. The input must be a number.")
        sys.exit(-1)
    return fValue


miles = getFloatValue("Enter a number of miles traveled: ")
gallons = getFloatValue("Enter the number of gallons on the last fill-up: ")

try:
    milesPerGallon = miles/gallons
except ZeroDivisionError as error:
    print("Error: ",error)
    print("You have entered an invalid value for the gallons. The input must greater than zero.")
    sys.exit(-1)


print(f"The miles per gallon is {milesPerGallon:.1f}")