Time converting problem. (24-hour military format to minutes)
Greetings, I'm a student who's currently in his first year and first semester in his CScourse and am having some issues with this program right here.
Okay, so you have to enter two different times in 24-hour format so the program could calculate the total
amount of time spent and then convert that time into minutes.
i.e. 100(start time) and 300(end time)
here's my shot at it:
Code:
#include <conio.h>
#include <stdio.h>
void main(){
int start_time;
int end_time;
int semi_time;
double final_time;
printf("Please enter the time you started (in military time): \n");
scanf("%d", &start_time);
printf("Please enter the time you ended (in military time): \n");
scanf("%d", &end_time);
semi_time = end_time - start_time;
final_time = semi_time * 0.60;
printf("The time that you have spent is: %.0f minute(s)\n", final_time);
getch();
}
Now the problem is, when I enter certain amounts of time, the output comes out
wrong.
When I enter "120" and "200" the output that comes out is "48 minutes", which is obviously incorrect, becauseit should be "40 minutes".
Now, I know I this is the part that I got wrong:
semi_time = end_time - start_time;
final_time = semi_time * 0.60;
But I can't figure out what to do with it to save my life.
Any help would be greatly appreciated. Thanks in advance.