Time calculation program

I'm into video editing and since I'm interested in learning c++ I thought I could write something.

So I produce videos and often I need music.
So let's say the video is 7 minutes and 10 seconds long.
It's hard to find 7 minute songs so I prefer to put 2 songs.

Now here's the tricky part:
The program should calculate 7 min 10 sec - 4 min 25 sec = 2 min 45 sec
In other words timeneeded (7:10) minus song1 (4:25) = song2 (2:45)
And the program should output you need one more song 2 min and 45 sec long.

I've been struggling with the conversions, I could get the minutes but I need seconds aswell. Tried some google help but I can't seem to figure it out.

Thanks for your time, cheers
One simple way is that you first change your minutes to seconds and then do calculation and then move them back to minutes.
I've been trying that before, but when I read your comment it just clicked in my head :D

I finished by program, thanks :D

Here's a gif http://i.imgur.com/rVZMUAE.gif

and the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <cstdlib>
#define SECS_PER_MIN 60

using namespace std;

int main()
{
    int a, b, c, d, e, f, g, h, i, j, secs_left;
    cout << "Enter Minutes And Seconds: ";
    cin >> a >> b; // a-min, b-sec
    cout << "You entered " << a << " Minutes And " << b << " Seconds." << endl;
    c=a*60; // a in sec
    d=c+b; // total sec of a & b
    cout << "Now Enter How Long Is The First Song In Minutes And Seconds: ";
    cin >> e >> f; // e-min, f-sec
    cout << "You enter " << e << " Minutes And " << f << " Seconds." << endl;
    g=e*60; // e in sec
    h=g+f; // total sec of e & f
    i=d-h; // what I need minus first song in sec
    j=i/60; // ^ in min
    secs_left = i % SECS_PER_MIN; // remaining sec
    cout << "You Need One More Song " << j << " Minutes And " << secs_left << " Seconds Long." << endl;      
    system ("pause");
    return 0;
}


:)
Topic archived. No new replies allowed.