213k views
4 votes
Justin Kace is promoting the metric system and wants people to be able to convert miles to kilometers and kilometers to miles. Develop a program that asks the user for a number of miles and converts miles to kilometers (multiplying miles by 1.609), and then asks for a number of kilometers and converts kilometers to miles (multiplying kilometers by 0.6214).

User Saner
by
4.5k points

1 Answer

5 votes

Solution :

//Program heading

Display "Kilometers to
$\text{Miles}$ and
$\text{Miles}$ to Kilometers Conversion Program"

//Get
$\text{Miles}$

Display "Enter the
$\text{miles}$: "

Input
$\text{miles}$

//Convert
$\text{miles}$ to kilometers and display result

converted_km =
$\text{miles}$ x 1.609

Display "Converted kilometers = " + converted_km

//Get Kilometers

Display "Enter the kilometers: "

Input km

//Convert kilometers to
$\text{miles}$ and display result

converted_
$\text{miles}$ = km x 0.6214

Display "Converted
$\text{miles}$ = " + converted_
$\text{miles}$

//Thank the user for using this program

Display "Thank you for using this program. Good-bye!"

Stop

Sample Output:

Kilometers to
$\text{Miles}$ and
$\text{Miles}$ to Kilometers Conversion Program

Enter the
$\text{miles}$: 10

Converted kilometers = 16.09

Enter the kilometers: 10

Converted
$\text{miles}$ = 6.214

Thank you for using this program. Good-bye!

User Samg
by
5.1k points