In this program we will compute the conversions between distances expressed in miles and in kilometers. The program will ask the user to: Enter a distance value followed by km (for kilometers) or mi...


In this program we will compute the conversions between distances expressed in miles and in kilometers. The program will ask the user to: Enter a distance value<br>followed by km (for kilometers) or mi (for miles): Store the number in a double object called dist and the units in a string object called units. Use if/else selection<br>statement to compute, based on the units entered, the distance in both miles and kilometers. Use distMI and distKM for the respective distances. The formulas for the<br>conversion are:<br>distKM = 1.609*distMI<br>distMI = distKM/1.609<br>In case, the units are not recognized, display a message stating so. Use the following sample output below.<br>Sample output 1:<br>Enter a distance value followed by km (for kilometers) or mi (for miles): 100 km<br>100 km = 62.1504 mi.<br>Sample output 2:<br>Enter a distance value followed by km (for kilometers) or mi (for miles): 530 mi<br>530 mi = 852.77 km.<br>Sample output 3:<br>Enter a distance value followed by km (for kilometers) or mi (for miles): 23 ni<br>The type of unit you entered 'ni' is not recognized.<br>

Extracted text: In this program we will compute the conversions between distances expressed in miles and in kilometers. The program will ask the user to: Enter a distance value followed by km (for kilometers) or mi (for miles): Store the number in a double object called dist and the units in a string object called units. Use if/else selection statement to compute, based on the units entered, the distance in both miles and kilometers. Use distMI and distKM for the respective distances. The formulas for the conversion are: distKM = 1.609*distMI distMI = distKM/1.609 In case, the units are not recognized, display a message stating so. Use the following sample output below. Sample output 1: Enter a distance value followed by km (for kilometers) or mi (for miles): 100 km 100 km = 62.1504 mi. Sample output 2: Enter a distance value followed by km (for kilometers) or mi (for miles): 530 mi 530 mi = 852.77 km. Sample output 3: Enter a distance value followed by km (for kilometers) or mi (for miles): 23 ni The type of unit you entered 'ni' is not recognized.

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here