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
|
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<iomanip>
#include<cmath>
using namespace std;
ofstream ofs("glavin_final_out.txt");
string message = "ENGR CIS 2485 Calaculating time to Current Date.";
string fot = "----------------------------End of Data----------------------------";
string no = "EOF MESSAGE - ";
string more = "Amanda Glavin, ";
string hardcoding = "July 30 2015, ";
string of = "Final ";
string anything = "All Done.";
string fin = "Following Instructions";
string twt = "20%";
string ten = "10%";
string hun = "100%";
string scr = "your score is ----------";
string pts = "100";
string dit = "Does It Run";
string doc = "Correct Doc's";
string frm = "Format";
string str = "Structure";
string nam = "Correct files/names";
string tot = "Total Scores";
string m = "Enter Month: ";
string d = "Enter Day: ";
string y = "Enter Year: ";
string calc = "1. Calculate time to Current Date.";
string over = "2. Quit.";
string select = "Enter your selection. " ;
string invalid = "That is an invalid selection. " ;
string dash = "/";
string ttl = "| Date | Seconds | Minutes | Hours | Days | Months | Year to Date |";
string tt2 = "| | | | | | | |";
string slash = "|";
string lin = "----------------------------------------------------------------------------------------------";
void header()
{
ofs << endl;
ofs << more << message << endl;
ofs << endl;
}
void title()
{
ofs << lin << endl;
ofs << ttl << endl;
ofs << tt2 << endl;
ofs << lin << endl;
}
void footer()
{
ofs << endl;
ofs << fot << endl;
ofs << endl;
}
void grading()
{
ofs << endl;
ofs << fin << setw(8) << twt << setw(25) << scr << endl;
ofs << dit << setw(19) << twt << setw(25) << scr << endl;
ofs << doc << setw(17) << ten << setw(25) << scr << endl;
ofs << frm << setw(24) << ten << setw(25) << scr << endl;
ofs << str << setw(21) << twt << setw(25) << scr << endl;
ofs << nam << setw(11) << twt << setw(25) << scr << endl;
ofs << tot << setw(18) << hun << setw(25) << scr << endl;
ofs << of << setw(23) << pts << setw(26) << scr << endl;
ofs << endl;
}
void eofmsg()
{
ofs << endl;
ofs << no << more << hardcoding << of << anything << endl;
}
class Today;
class Date
{
private:
int month, day, year;
long temp;
public:
Date(int=7, int=30, int=2015);
operator Today();
void getDate();
};
class Today
{
private:
int ye, mo;
long da, ho, mi, se;
public:
Today (int, int, long, long, long, long);
void showTime();
};
Date::Date(int mm, int dd, int yyyy)
{
month = mm;
day = dd;
year = yyyy;
}
Date::operator Today()
{
int YP, MP;
long DP, HP, min, sec;
YP = 2015 - year;
MP = year * 12 + abs(7-month);
DP = YP * 365 + MP * 31 + abs(30-day);
HP = DP * 24;
min = HP * 60;
sec = min * 60;
return (Today(YP, MP, DP, HP, min, sec));
}
void Today::showTime()
{
ofs << slash << ye << slash << mo << slash << da << slash << ho << slash << mi << slash << se;
}
Today::Today(int nYear, int nMonth, long nDay, long nHour, long nMin, long nSec)
{
ye = nYear;
mo = nMonth;
da = nDay;
ho = nHour;
mi = nMin;
se = nSec;
}
void Date::getDate()
{
int menuSelection;
int month, day, year;
int quit=0;
while (quit != 1)
{
cout << calc << endl;
cout << over << endl;
cout << endl;
cout << select << endl;
cin >> menuSelection;
while (menuSelection < 1 || menuSelection > 3)
{
cout << invalid << endl;
cin >> menuSelection;
}
switch (menuSelection)
{
case 1:
{
cout << m << endl;
cin >> month;
cout << d << endl;
cin >> day;
cout << y << endl;
cin >> year;
Date a(month, day, year);
a.getDate();
Today b;
b=Today(a);
ofs << slash << setw(6) << month << dash << day << dash << year << setw(6) << slash << setw(11);
b.showTime();
ofs << setw(7) << slash << endl;
break;
cin >> menuSelection;
}
case 2:
quit = 1;
break;
}
}
}
int main()
{
header();
title();
Date a(7,30,2015);
a.getDate();
footer();
grading();
eofmsg();
return 0;
}
| |