Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Create a program that can convert from kilograms to pounds, pounds to kilograms, liters to gallons, and gallons to liters.This program will help you develop your skills using input, output,...

1 answer below »

Create a program that can convert from kilograms to pounds, pounds to kilograms, liters to gallons, and gallons to liters.

This program will help you develop your skills using input, output, arithmetic, and string formatting.


info iconHow to do it?

When the program starts,theuser should be presented with a menu similar to the following:


Please select the conversion you would like to do:

1: Kilograms to Pounds
2: Pounds to Kilograms
3: Liters to Gallons
4: Gallons to Liters
5: Exit

Selection (1-5):

  • After the user makes the selection, the program should prompt them for the value to convert. If the users input an invalid selection, the program should display:
  • You have not typed a valid selection, please run the program again.
  • The program should then exit.
  • The output of the number should be formatted so that it has two decimal places.For example: 16.53
  • The output should include the converted value and the converted units.

These are the conversion formulas:

ConversionFormulaExample
Kilograms to PoundsMultiply the kilogram value by 2.20467.5 kilograms x 2.2046 = XXXXXXXXXXpounds
Pounds to KilogramsDivide the pound value by 2.204625 pounds / 2.2046 = XXXXXXXXXXkilograms
Liters to GallonsDivide the liter value by XXXXXXXXXX2 liters / XXXXXXXXXX = XXXXXXXXXXgallons
Gallons to LitersMultiply the gallon value by XXXXXXXXXX5 gallons * XXXXXXXXXX = XXXXXXXXXXliters


Sample output:


Please select the conversion you would like to do:

1: Kilograms to Pounds
2: Pounds to Kilograms
3: Liters to Gallons
4: Gallons to Liters
5: Exit

Selection (1-5): 1

Enter Kilograms 100

220.46 Pounds

Answered 1 days After Jan 26, 2024

Solution

Bhaumik answered on Jan 27 2024
11 Votes
Conversion Program
Output:
Explanation:
Let us go through the code step by step to understand how it works:
1) Conversion Functions:
· The program defines four conversion functions: `kg_to_pounds`, `pounds_to_kg`, `liters_to_gallons`, and `gallons_to_liters`. These functions implement the conversion formulas provided in the problem statement.
2) Main Program (`main` function):
· The `main` function is where the main logic of the program resides. It runs in a loop until the user chooses to exit.
· Inside the loop: The user is presented with a menu using the `print` statements.
· The program attempts to get the user's selection as an integer using `int(input(...))`. If the user enters a non-integer value, a `ValueE
or` is caught, and an e
or message is displayed....
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here