Sign in to follow this  
Out-Take

Quick Question

Recommended Posts

OK I managed to get it to tell me whether the year input is a leap year or not, but now I need to know how to get the month. I've already done this much:

#include <iostream>
using namespace std;


int getYearValue(int year);
int getCenturyValue(int year);
int getMonthValue (int month, int year);
void getInput (int& month, int& day, int& year);
int century (int year);
int Year (int year);

int main(void)
{
int month, day, year, yy;
int getMonthValue = (month, year);
cout << "Input a date" << endl;
cin >> month >> day >> year;

int century = year/100;
int Year = year%100;

int getCenturyValue = 2*(3 - (century%4));

int getYearValue = Year/4;

int remainder = (getCenturyValue + getYearValue);

bool isLeapYear(int year);
{
if (year%400 == 0 || year%4 == 0)
{
cout << " is a leap year \n";
}
else
{
cout << " is not a leap year \n";
}
}



NOTE: Some things in there have yet to be done, I'm just trying to find the best way of doing this.

Share this post


Link to post
Share on other sites
The easiest way is just to just use a localtime struct and not have to compute any of this.

http://www.cplusplus.com/reference/clibrary/ctime/localtime/

If you have to do this for your homework then you're probably on your own.

Also your leap year formula is wrong.
Quote:

Wikipedia: Years that are evenly divisible by 100 are not leap years, unless they are also evenly divisible by 400, in which case they are leap years.


EDIT: Actually I have no idea what you're trying to do with all that year=year%100 formulas, but in any case any year that is divisible by 4 is also divisible by 400, so it's redundant at best.

Share this post


Link to post
Share on other sites
Ok I have a large majority of it done. All I need help with now is to get the correct number for the day of the week. I need to do
(day + getMonthValue + getCenturyValue + getYearValue)/7
but what I need is to isolate the remainder. So if all that equaled 4 + 6 + 10 + 6 = 26. 26/7 = 3 remainder 5. The problem is I don't know how to get that remainder for my day.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this