How am I doing with carry and overflow with this code?

  c++, if-statement, integer-overflow

I just have some issues with carry and overflow with this code I’ve been assigned to create. The assessor has asked me to deduct values from a double (which I don’t know is the right function). Also, do I need secD and minD?

here is my code:

#include <iostream>

using namespace std;

int main (){


    double degA;
    double degB;
    double degC;
    double minA;
    double minB;
    double minC;
    double minD;
    double secA;
    double secB;
    double secC;
    double secD;
    double carryM;
    double carryS;

    cout << "input all values for degree number one in this order: Degree┬░Minute'Second. Repeat this process when I say so.";
    cin >> degA;
    cin >> minA;
    cin >> secA;

    cout << "do it again";
    cin >> degB;
    cin >> minB;
    cin >> secB;

    secD = secA + secB;

    if (secD >= 60){
        secC = secD - 60;
        carryS = 1;
    }
    else {
        secC = secD;
        carryS = 0;
    }
    minD = minA + minB + carryS;

    if (minD >= 60){
        minC = minD - 60;
        carryM = 1;
    }
    else {
        minC = minD;
        carryM = 0;
    }
    degC = degA + degB + carryM;
    cout << degC << "┬░" << minC << "'" << secC;





}

Source: Windows Questions C++

LEAVE A COMMENT