Advice with C++ Calendar

Hi, I am a beginner in programming and need some advice on my program. I don't need it solved but I need a little help.
I need help with a way to implement the equation to find the first day of the week and how I am going to set the calendar for every month on its start day.
I know that my code is a mess, any other advice would be nice. I dont need a solve but a little help.

#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, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
const string MONTHS[13] = { " ", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November", "December" };
bool isleapyear(const int year);
void printyear(const int year);
int dayofweek(const int day, const int month, const int year);
int main(void){
int year1;
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(year1);

return 0;


}


bool isleapyear(const int year){

if (((year % 400 == 0)) == true &&! (year % 100 == 0)){
daysinmonths[2] = 29;
cout << "This is a leap year.\n" << endl;
}
else if ((year % 4 == 0) == true){
daysinmonths[2] = 29;
cout << "This is a leap year.\n" << endl;
}

return year;
}

int dayofweek(const int day, const int month, const int year){
int a, y, m, d;
a = (14 - month) / 12;
y = year - a;
m = 1 + 12 * a - 2;
d = (day + y + y / 4 - y / 100 + y / 400 + (31 * m / 12)) % 7;
for (int x; x <= startday[d]; x++){

}
return year, d;
}
void printyear(const int year){

isleapyear(year);



string spaces = " ";


int length = 0;
cout << setw(17) << year;
for (int count = 1; count <= daysinmonths[count]; count++)
{

length = MONTHS[count].length();
length = (30 - length) / 2 + length;

cout << setw(length);
cout << endl << endl << endl << setw(length) << MONTHS[count] << endl;

cout << " Sun Mon Tue Wed Thu Fri Sat\n";


}
Last edited on
I dont need a solve but a little help

OK then I'll give you a little tease - here's a program I wrote sometime back, you can look at it if you wish (and/or can't resist): http://pasted.co/65c3ab98


Topic archived. No new replies allowed.