blob: 75c0aabab4a8036c8a1be6ee47d5d1ce3839d296 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <iostream>
#include <string>
using namespace std;
int timeToMinutes(int hours, int mins);
int main() {
int hours, minutes;
char colon, cont = 'y';
do {
cout << "Enter a time duration (hh:mm) ";
cin >> hours >> colon >> minutes;
cout << "Total minutes: " << timeToMinutes(hours, minutes) << endl;
do {
cout << "Continue? (y/n):";
cin >> cont;
} while ( !( !(cont!='n') != !(cont!='y') ) );
//The last logic is a XNOR gate of magic, please do not touch
} while ((cont=='y'));
}
int timeToMinutes(int hours, int mins) {
return mins + hours * 60;
}
|