Write a program to calculate the estimated journey time of a train. The
program should request and read the distance in miles and the average
speed in miles per hour, and display the estimated journey time in hours
and minutes to the nearest minute.
Test your program with:
a) Distance = 1.01, speed = 1. [Result should be 1 hour & 1 minute.]
b) Distance = 1.005, speed = 1. [Result should be 1 hour & 0 minutes.]
here are my codes:
#include <stdio.h>
#include <stdlib.h>
int main()
{
float dist, speed;
float time;
printf("Enter Distance in miles: ");
scanf("%f", &dist);
printf("Enter Speed in miles per hour: ");
scanf("%f", &speed);
time=dist/speed;
printf("The estimated journey is %.2f", time);
system("pause");
return(0);
}
as in the question is said to display the time in hours and minutes! my problem here is i do not know how to do it any help? i think that the final should be "1 hour & 1 minute" display on the window