Can I suggest that you don't do this? C++ has
else if (condition){}
as well as
else {}
It looks like you are mixing the 2 concepts together, the proper format looks like this:
1 2 3 4 5 6 7 8 9 10 11 12
|
if (condition) {
//statements
}
else if (condition) {
//statements
}
else if (condition) {
//statements
}
else {
//statements
}
|
It might work at the moment, but it will confuse you one day & is causing undue complication in your code, because you are effectively putting all the
else if
's inside the else.
You also need some functions - lines 67 - 71 would be a great example, although i would the results into an array in order, rather than a whole lot of code to retrieve the right value (40 lines of code covering 6 permutations versus 3 lines of code)
Your assignment seems to require conversion from minute and seconds into decimal minutes, but you don't do that anywhere.
Also, you shouldn't use equality operators on floats or doubles directly. It may work now, but it will cause problems later on.
Floating point numbers are stored as binary fractions, and cannot represent all real numbers exactly. Consider this:
1 2 3 4
|
float a = 0.1; // a == 0.09999997
float b = 10 * a; // b == 0.9999997
if (b == 1.0) //always false
|
Changing the type to double doesn't help.
To fix this, Google epsilon.