/*************************************************
Military Clock Increment

Write a function 

   void int(int&);

That increments an int representing a 24-hour
military clock.
*************************************************/
#include <iostream>
using namespace std;

void inc(int&);
void writemil(int);

/************************************
 ** main()
 ************************************/
int main()
{
  // Enter starting time (military) and minutes M
  int T, M;
  cout << "Enter starting time: ";
  cin >> T;
  cout << "Enter number of minutes: ";
  cin >> M;

  // Icrement time by M minutes
  for(int i = 0; i < M; i++)
    inc(T);
  
  // Write out time (look out for leading 0's)
  cout << "Time is " ;
  writemil(T);
  cout << endl;

  return 0;
}

/************************************
 ** inc(T) - increment an int as a 24
 ** hour military clock.
 ************************************/
void inc(int& T)
{
  T++;
  if (T % 100 >= 60)
    T = (T/100 + 1)*100;
  if (T == 2401)
    T = 1;
}

/************************************
 ** writemil(T) - write int as if the
 ** time were military time.
 ************************************/
void writemil(int T)
{
  if (T < 10)
    cout << "000";
  else if (T < 100)
    cout << "00";
  else if (T < 1000)
    cout << "0";
  cout << T;
}