I have finished everything with my code except for printing the year ond the months to a file.
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
const int MIN = 1582;
const int MAX = 9999;
int startday[7] = { 0, 1, 2, 3, 4, 5, 6 };
int daysinmonths[13] = { 0, 30, 27, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30 };
const string MONTHS[13] = { " ", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November", "December" };
bool isleapyear(const int year);
void printyear(ofstream & f, const int year);
int dayofweek(int month, int year);
int main(void){
int year1;
ofstream myfile;
myfile.open("calendar.txt");
cout << "Please enter a year between 1582 and 9999\nto obtain the full calendar year of that date.\n";
cin >> year1;
while (year1 < MIN || year1 > MAX){
cout << "Incorrect input, please enter a year within the range of 1582 through 9999!\n";
cin >> year1;
}
printyear(myfile, year1);
return 0;
}
bool isleapyear(const int year){
if ((year % 400 == 0) == true &&! (year % 100 == 0)){
daysinmonths[2] = 28;
cout << "This is a leap year.\n" << endl;
}
else if ((year % 4 == 0) == true){
daysinmonths[2] = 28;
cout << "This is a leap year.\n" << endl;
}
return year;
}
int dayofweek(const int month, const int year){
int a, y, m, d;
a = (14 - month) / 12;
y = year - a;
m = month + 12 * a - 2;
d = (1 + y + y / 4 - y / 100 + y / 400 + (31 * m / 12)) % 7;
for (int x = 0; x < d; x++){
cout << " ";
}
for (int count = 0; count <= daysinmonths[month]; count++){
if ((count + d) % 7 == 0){
cout << endl << " ";
}
if (count + 1 < 10)
cout << " ";
cout << count + 1 << " ";
}
return year;
}
void printyear(ofstream & f, const int year){
isleapyear(year);
int length = 0;
cout << setw(17) << year;
for (int count = 1; count <= daysinmonths[count]; count++)
{