Please Help me

Please help me, I try to write a program that includes a user-defined function named dayOfWeek that will take a date as three separate integer arguments representing the month, day and year, and return the day-of-week value as determined by Zeller's method.
The following is my code, but this code does not work for the Feb and how do I remove the number before the weekday.
Please help me. Thanks



#include <iostream>
#include <cmath>
using namespace std;

int main()
{
char yesno='y';
while(yesno=='Y' || yesno=='y')
{
int d;
// d = day of the month
int m;
// m = month (3 = March, 4 = April, 5 = May, 6 = June, 7 = July, 8 = August, 9 = September, 10 = October, 11 = November, 12 = December, 13 = Janurary, 14 = February)
int y;
// Year
int k;
// k = year of the century, last two digits.
int j;
// j = century
int dayOfWeek;
// h = day of the week (0 = Saturday, 1 = Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thrusday, 6 = Friday)

cout << "Please enter a date as mm dd yyyy: \n";
cout << "For the month, please note: 3 = March, 4 = April, 5 = May, 6 = June, 7 = July, 8 = August, 9 = September, 10 = October, 11 = November, 12 = December, 13 = Janurary, 14 = February" << endl;
cin >> m >> d >> y;
j = y /100;
k = y % 100;
dayOfWeek = (d + 26 * (m + 1) / 10 + k + k/4 + j/4 + 5*j) % 7;

cout << "This date is on \n"<< dayOfWeek;


switch (dayOfWeek)
{
case 0:
cout << "Saturday\n";
break;
case 1:
cout << "Sunday\n";
break;
case 2:
cout << "Monday\n";
break;
case 3:
cout << "Tuesday\n";
break;
case 4:
cout << "Wednesday\n";
break;
case 5:
cout << "Thursday\n";
break;
case 6:
cout << "Friday\n";
break;
default:
cout << "That is not a possible weekday.\n";
}

cout<<"continue? (y or n) \n";
cin>>yesno;

}
return 0;
}
Last edited on
Topic archived. No new replies allowed.