← Back
Code Challenge 1.3 - Miles to Kilometers Calculator
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
Challenge Tasks
- Create a console project named Challenge 1-3.
- Prompt the user to enter a distance in miles.
- Convert the miles value to kilometers using the formula Km = Mi × 1.609.
- Optionally, round the answer to two decimal places.
- Display the calculated kilometers to the user in a clear and formatted manner.
Sample Output
--- Miles to Kilometers Calculator ---
Enter the distance in miles: 12.5 [Enter]
12.5 miles is equal to 20.11 kilometers