So this program is supposed to take the day, month and year and be able to show you the weekday of that particular date. Problem is I always get the output 84 for some reason. Don't understand where that number is coming from or what I necessarily need to fix?
#include <iostream>
#include <string>
using namespace std;
int month (int mm)
{
if (mm == 1)return 13;
if (mm == 2)return 14;
if (mm == 3)return 3;
if (mm == 4)return 4;
if (mm == 5)return 5;
if (mm == 6)return 6;
if (mm == 7)return 7;
if (mm == 8)return 8;
if (mm == 9)return 9;
if (mm == 10)return 10;
if (mm == 11)return 11;
if (mm == 12)return 12;
}
int weekday_number (int wn)
{
int mm;
int d;
int y;
wn=(d+5+(((26*(mm + 1))/10)+((5*(y%100))/4)+((21*(y/100))/4)))%7;
return wn;
}
int main()
{
int d;
int mm;
int y;
int wn;
cout << "Please enter a date (Format: month/day/year) and I'll compute the weekday: " << endl;
cout << "Date Example: 01/20/2012" << endl;
cin >> mm >> d >> y;
cout << wn << endl;
if (wn == 0)
{
cout << "Monday";
}
else if (wn == 1)
{
cout << "Tuesday";
}
else if (wn == 2)
{
cout << "Wednesday";
}
else if (wn == 3)
{
cout << "Thursday";
}
else if (wn == 4)
{
cout << "Friday";
}
else if (wn == 5)
{
cout << "Saturday";
}
else if (wn == 6)
{
cout << "Sunday";
}
else
{
cout << "Error Occured" << endl;
}
system ("pause");
return 0;
}