Do you guys get errors when you compile

I had a friend of mine check this for logic errors, and he says he keeps getting errors with the code. I've compiled it on a few different sites now including an IDE and it's compiling fine. Does everything look okay? Can you guys compile it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//Ashton Dreiling
//Seconds exercise
#include <iostream>
#include <stdlib.h>

using namespace std;

//module prototypes
void calculateDaysHoursMinsAndRemainSecs (double &Days, double &Hours, double &Minutes, double &remainingSeconds,
                                          int seconds);

//global constants
const int VALUETOCALCULATEDAYS = 86400;
const int VALUETOCALCULATEHOURS = 3600;
const int VALUETOCALCULATEMINS = 60;
const int VALUETOCALCULATEREMAINMINS = 60;

int main()
{   //some variables
    double Days;
    double Hours;
    double Minutes;
    double remainingSeconds;
    int seconds;

    cout << "We are going to have you input an amount of seconds to determine the days, hours, minutes, and remaining seconds." << endl;
    cout << "Please enter the amount of seconds of your choice." << endl;
    cin >> seconds;
    cout << "You typed in " << seconds << " seconds." << endl;
    cout << "We will now determine the days, hours, minutes, and remaining seconds based off of your input." << endl;

    //pass variables to calculate days, hours, minutes, and remaining seconds
    calculateDaysHoursMinsAndRemainSecs(Days, Hours, Minutes, remainingSeconds, seconds);
    cout << "There are " << Days << " Days." << endl;
    cout << "There are " << Hours << " Hours." << endl;
    cout << "There are " << Minutes << " Minutes." << endl;
    cout << "There are " << remainingSeconds << " remaining seconds." << endl;



    system("Pause");

    return 0;
}//end main

void calculateDaysHoursMinsAndRemainSecs(double &Days, double &Hours, double &Minutes, double &remainingSeconds, int seconds)
{   //Calculating values
    Days=(seconds/VALUETOCALCULATEDAYS);
    Hours=(seconds/VALUETOCALCULATEHOURS);
    Minutes=(seconds/VALUETOCALCULATEMINS);
    remainingSeconds=(seconds % VALUETOCALCULATEREMAINMINS);


}//end calculateDaysHoursMinsAndRemainSecs 
It compiled ok for me. However the algorithm used in function calculateDaysHoursMinsAndRemainSecs() appears suspect, the results will be wrong.
What did I do wrong?
Your friend is making the same stupid mistake that many posters here make - in thinking that it's useful to tell you that there are errors, but not to tell you what those errors are.

If he told you what the errors are, then you could look at your code, and see why it might be generating those errors. But since he hasn't, then his comments are of no help to you.
Last edited on
What did I do wrong?

The figures for Days and remainingSeconds appear correct.

However, the number of Hours should be in the range 0 to 23 and the number of Minutes should be in the range 0 to 59.

Or at least that would be what I'd expect the output to be.
http://prntscr.com/bjqbp8
I was under the impression I was using the right numbers.
You may be right. The question wasn't quite what I expected. Nevertheless your interpretation is apparently the right one.
Topic archived. No new replies allowed.