Back

Code Challenge 1.3 - Miles to Kilometers Calculator

divider

Objective

Create a console application that converts a distance from miles to kilometers based on user input.

Skills to Practice

  • Prompting a user for input
  • Saving user input to variables
  • Converting input to the correct data type (if necessary)
  • Performing arithmetic calculations
  • Formatting custom output using variables
divider

Challenge Tasks

  1. Create a console application named MiKmCalculator-LastName
  2. Complete the following tasks:
    • Prompt the user to enter a distance in miles.
    • Convert the miles value from the user to the equivalent value in Kilometers.
    • Formula: Km = Mi × 1.609
    • Optionally, round the answer to two decimal places.
    • Display the calculated Kilometers value to the user in a clear and formatted manner.

Sample Output

Miles to Kilometers Calculator
--- Miles to Kilometers Calculator ---
Enter the distance in miles: 12.5 [Enter]
12.5 miles is equal to 20.11 kilometers