I am trying to write a simple console application that will accept a string from the keyboard (representing a time period in the format HH:MM). This string must them be decomposed into two integers for hours and mins before being resolved into total mins (i.e. 02:20 would resolve to 140 mins etc). The resulting calculation should then be printed to the screen.
This is my code so far
Output I am trying to print
Any help would be appreciated, thanks in advance.
This is my code so far
Code:
#include <iostream> //include iostream to get access to cin and cout
#include <string> //include string to get access to a string variable.
using namespace std;
class time {
int Hr, Min;
public:
void set_values(int);
void Show(void);
};
int main()
{
std::string time;
int hours = 60;
int min = 60;
void set_values(int) {
Hr = Secs / 3600;
Min = (Secs % 3600) / 60;
}
cout << "Specify time (HH:MM) : ";
cin >> min;
//Specify system pause
system("PAUSE");
return 0;
}
Output I am trying to print
Code:
Specify Time (HH:MM) : 02:20
02:20 = 140 Mins !
Any help would be appreciated, thanks in advance.