Write a Java program which accepts distance in kilo meters as input and displays its Miles equivalent, or vice versa, as per the choice of user.
Write a Java program which accepts distance in kilo meters as input and displays its Miles equivalent, or vice versa, as per the choice of user.
Share
Below is the Java program that accepts distance in kilometers as input and displays its miles equivalent, or vice versa, as per the choice of the user:
This program prompts the user to enter their choice – whether they want to convert kilometers to miles or miles to kilometers. Based on the user's choice, it then prompts the user to enter the distance value and performs the conversion accordingly. The conversion formulas are used to convert between kilometers and miles. Finally, the program displays the converted distance to the user.