Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Programming. Use Code :: Blocks to write a program for this exercise: As part

ID: 3686256 • Letter: C

Question

C Programming. Use Code :: Blocks to write a program for this exercise:

As part of a scientific expedition, you are tasked with recording the daily miles traveled. The expedition's findings will be published in journals worldwide therefore the logging needs to be done with both miles and kilometers. Write a program which will read in the miles traveled for each leg of the journey. The program should have a function named milesToKm which will convert from mile distances to km distances. As the user enters values, print the input and the conversion. When the user enters a 0 (can be defined as a constant) the input/conversion loop should terminate. After the loop terminates, print the total distance traveled in miles as well as in kilometers. Also print the longest leg of the trip (the largest entry and it's converted value).

Conversion: 1 mile = 1.60934 km

Sample Input:

10.2

12.5

16.3

10.8

11.3

20.1

8.30

0

Sample Output:

Mile and Km logger

Enter distance in miles:10.2

   10.20 miles = 16.42 kilometers

Enter distance in miles:12.5

   12.50 miles = 20.12 kilometers

Enter distance in miles:16.3

   16.30 miles = 26.23 kilometers

Enter distance in miles:10.8

   10.80 miles = 17.38 kilometers

Enter distance in miles:11.3

   11.30 miles = 18.19 kilometers

Enter distance in miles:20.1

   20.10 miles = 32.35 kilometers

Enter distance in miles:8.3

8.30 miles = 13.36 kilometers

Enter distance in miles:0

--------------------------

Total Miles: 89.50

Total Km: 144.04

Longest Leg: 20.10 miles (32.35)km

Explanation / Answer

Hi below i have written the sample code for your reference which will convert from mile distances to km distances.

#include<stdio.h>
#include<conio.h>
void main()
{
float miles,km;
printf("Enter the distance in miles ");
scanf("%f",&miles);
km=1.609*miles;
printf("Distance in kilometers = %f",km);
getch( );
}