1. ## Help with Time? Please....

I run cross country and have made a program to calculate the splits for my times, for instance if I run 3 miles in 17:33 I would put in the minutes and seconds and it would tell me how long it took me to run per mile.

Currently my math function that I wrote, takes in minutes and seconds as seperate int variables and performs some really long and drawn out math on them. This works, but sometimes my split times are only accurate within 2 seconds or so because of the int varables, I couldn't figure out how to do it with double variables.

I know about CTime but do not know how to use it, could you please tell me how to declare a CTime variable with minutes = 17 and seconds = 30, then divide that by three and store in a new variable for output, or at least tell me how to divide minutes and seconds precisley, like up to two decimals.

Thanks,
RunXC410.

2. have you tried to input them as doubles and then store it back into a double, because if you have the minutes and seconds and ints and try to store them into a double, the answer will still be an int.

alpha

3. Why not convert the minutes and seconds into seconds, divide by three (or whatever), then convert back? I would think this would be pretty easy. You'll need to make your seconds always a double though so you can store the decimal place when you convert back.

4. By the way, I'm guessing from your login name that you run a mile in 4:10 - if true, thats pretty fast

5. Convert your running time to seconds, then do the calculations.
Code:
```#include <iostream>

using namespace std;

struct TimeType
{
int min;
int sec;
};

int main(void)
{
int miles;
TimeType running_time;
TimeType time_per_mile;
int mile_time_in_sec, time_in_sec;

cout << "How many miles?";
cin >> miles;
cout << "Enter your time in minutes and seconds";
cin >> running_time.min >> running_time.sec;

time_in_sec = running_time.min * 60 + running_time.sec;
mile_time_in_sec = time_in_sec / miles;
time_per_mile.min = mile_time_in_sec / 60;
time_per_mile.sec = mile_time_in_sec % 60;

cout << "running time:" << running_time.min << " minutes " <<
running_time.sec << " seconds." << endl;
cout << "time per mile:" << time_per_mile.min << " minutes " <<
time_per_mile.sec << " seconds." << endl;

return 0;
}```