Thread: Calender

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    14

    Calender

    Ok, I'm sure everyone is sick of this one. I have to make a calender. Problem is that it has to be able to print from the year 0 until the year 10,000 so Zeller is no help for me. I think i am having problems in the function that does the for loop. Advice Please! thanks:


    #include <iostream>
    #include <cmath>

    using namespace std;


    int whatDay(int day)
    {

    if (day%7==0){
    cout<<"TheCOunter"<<day<<endl;
    return(7);}
    if (day%6==0){
    cout<<"TheCOunter"<<day<<endl;
    return(6);}
    if (day%5==0){
    cout<<"TheCOunter"<<day<<endl;
    return(5);}
    if (day%4==0){
    cout<<"TheCOunter"<<day<<endl;
    return(4);}
    if (day%3==0){
    cout<<"TheCOunter"<<day<<endl;
    return(3);}
    if (day%2==0){
    cout<<"TheCOunter"<<day<<endl;
    return(2);}
    if (day%1==0){
    cout<<"TheCOunter"<<day<<endl;
    return (1);}
    }

    int isLeap(int year1)
    {
    int dayInMonth=28;

    if (year1%4==0){
    dayInMonth=29;
    if (year1%100==0){
    dayInMonth=28;
    if (year1%400==0)
    dayInMonth=29;}}

    return (dayInMonth);
    }

    int firstDay(int calenderYear)
    {
    long counter=0;
    int theCounter=0;

    for(int year=0;year<calenderYear;year++){
    if (year == 0)
    counter=theCounter+331+isLeap(year);
    else
    counter=theCounter+337+isLeap(year);
    theCounter+=whatDay(counter);
    //counter=1;
    //cout<<counter<<endl;
    }
    //theCounter--;
    return (whatDay(theCounter));


    }



    int main(void)
    {

    int dayInMonth=0,calenderYear1=0 ;
    int x=0;

    cout<<"hello"<<endl;
    cin>> calenderYear1;

    cout<<"The first day is "<<firstDay(calenderYear1)<<endl;
    cout<<calenderYear1<<endl;
    return(0);
    }

  2. #2
    registereduser
    Guest
    needs code tags, then i'll read it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calender..
    By dahenkiz in forum C Programming
    Replies: 2
    Last Post: 11-09-2005, 01:25 PM
  2. Calender Control
    By iglod in forum Windows Programming
    Replies: 1
    Last Post: 09-14-2002, 06:38 AM
  3. Replies: 1
    Last Post: 01-29-2002, 02:49 AM
  4. Displaying a calender in this format...
    By Claire in forum C++ Programming
    Replies: 1
    Last Post: 01-28-2002, 04:24 AM
  5. Calender
    By confused in forum C Programming
    Replies: 2
    Last Post: 11-28-2001, 05:44 AM