Guidance on finishing a very old project

Long story short, I was coding a Elapsed Time Calculator and never got around to finishing it due to school. I also have been not programming too much in the past year, year in a half. I would like some guidance on finishing the program.

The elapsed time finder uses the Julian Calender and (and some simple equations) to find the elapsed time between two given dates. I haven't got it running ever.
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

Code:

STARTED: 12/22/2010 12:25

LAST MODIFIED: 12/22/2010 23:03
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <iomanip>
#include <stdexcept>
#include <cmath>
#include <ctime>

using namespace std;

///////////////////////////////
namespace first {            //
    double jdn;//
    double dec;     //
}                            //
                             /////////////// 
namespace second {           //
    double jdn;//
    double dec;      //
}                            //
///////////////////////////////

// ****FUNCTION PROTOTYPE****

double round2 {double x, double y}
{
    x = floor( x * pow(10.0, n) + 0.5) / pow(10.0, n);
    return x;
}

// **** END FUNCTION PROTOTYPE ****


// ****CLASSES****
class date {
    const int year;
    const unsigned month;
    const double day;

        public:
            explicit date {int y, unsigned m, double d}
            : year {y}, month {m}, day {d}
            { if (((year < -4716) or (year > 9999))
            or ((month == 0) or (month > 12))
            or ((day 1.0) or (day > 32.0)))
            {
                throw std::domain_error ("Invalid Date");
            }
            }
    int y() const {return year;}
    unsigned m() const {return month;}
    double d() const {return day;}
};

/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////

double computeJulianDay(const Date& date)
{
    int yr = date.y();
    unsigned mo = date.m();

    if (mo == 1 or mo == 2)
    {
        yr -= 1;
        mo += 12;
    }


    const int a = yr / 100;
    const int b = 2 - a + (a / 4);
    const double result = floor(365.25 * (yr + 4716))
        + floor(30.6001 * ( mo + 1))
        + date.d() + b - 1524.5;

    return result;
}

//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////

class Time
{
private:
    time_t rawtime;
    struct tm * timeinfo;
    int hour, minute, second;
public:
    Time()
    : rawtime(time(0)), timeinfo(localtime(&rawtime)),
      hour(timeinfo->tm_hour), minute(timeinfo->tm_min),
      second(timeinfo->tm_sec)
        {}
    int H() const { return hour; }
    int MN() const { return minute; }
    int S() const { return second; }
    };

///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////

    class Date
{
private:
    time_t rawtime;
    struct tm * timeinfo;
    int year, month, day;
public:
    Date()
    : rawtime(time(0)), timeinfo(localtime(&rawtime)),
      year(timeinfo->tm_year), month(timeinfo->tm_mon),
      day(timeinfo->tm_mday)
        {}
    int Y() const { return year + 1900; }
    int M() const { return month + 1;}
    int D() const { return day; }
    };

///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////


class TimeInput
{
    const int hour;
    const int minute;
    const int second;
public:
    explicit Time(int h, int m, int s)
    : hour(h), minute(m), second(s)
    {
        if ((hour >= 24) or (minute >= 60) or ( second >= 60))
                 {
            throw std::domain_error("Invalid date.");
        }
    }

    int h() const {return hour;}
    int m() const {return minute;}
    int s() const {return second;}
};


///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

double dectime (const TimeInput& ti)
{
    int hr = ti.h();
    int min = ti.m();
    int sec = ti.s();

    const double a = ((hr * 60 * 60) + (min * 60) + sec);
    const double result = (a / 86400);
    return result;
}



/* START OF MAIN FUNCTION */




int main ()
{
    int y, m, d; // Date
    int h, mn, s; // time
    double ajd;




    cout << "ELAPSED TIME" << endl;
    cout << endl;

    cout << "Year" << endl;
    cout << endl;
    cin >> y;

    cout << "Month" << endl;
    cout << endl;
    cin >> m;

    cout << "Day" << endl;
    cout << endl;
    cin >> d;

    cout << "Hour (24 Hr format)" << endl;
    cout << endl;
    cin >> h;

    cout << "Minute" << endl;
    cout << endl;
    cin >> mn;

    cout << "Second" << endl;
    cout << endl;
    cin >> s;







    TimeInput ti;
    Time t;
    try {
        first::dec = dectime(ti(h,mn,s));
        second::dec = dectime (ti(t.h(), t.mn(), t.s()));
    } catch (std::domain_error& ex) {
        cerr << ex.what() << std::endl;
        cin.get();
        return 1;

    ad = modf (





    Date d;

    try {
        first::jdn = computeJulianDay(Date(y,m,d));
        second::jdn = computeJulianDay(Date(d.y(),d.m(),d.d()));
    } catch (std::domain_error& ex) {
        cerr << ex.what() << std::endl;
        return 1;
    }

Thank you.
- Enigma
P.S. I know there are some minor errors like unused/undeclared variables...
Last edited on
Anyone?
Last edited on
what's your problem?
I don't understand where to go from here. It just work...
Topic archived. No new replies allowed.