Advertisement
JOHNYTHEWINNER

Score time

Jan 23rd, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6.  
  7. int main()
  8. {
  9.     int time1;
  10.     int time2;
  11.     int time3;
  12.  
  13.     do
  14.     {
  15.         cin.clear();
  16.         cin >> time1;
  17.     } while (cin.bad() || time1 < 0 || time1> 50);
  18.  
  19.     do
  20.     {
  21.         cin.clear();
  22.         cin >> time2;
  23.     } while (cin.bad() || time2 < 0 || time2> 50);
  24.  
  25.     do
  26.     {
  27.         cin.clear();
  28.         cin >> time3;
  29.     } while (cin.bad() || time3 < 0 || time3> 50);
  30.     int totaltimesec = (time1 + time2 + time3);
  31.     double totaltimemin = abs(totaltimesec / 60);
  32.     double totaltimesec1 = abs(totaltimesec - totaltimemin * 60);
  33.     if (totaltimesec1 < 10)
  34.     {
  35.         cout << totaltimemin << ":0" << totaltimesec1 << endl;
  36.     }
  37.     else
  38.     {
  39.         cout << totaltimemin << ":" << totaltimesec1 << endl;
  40.     }
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement