I try to make monthly calendar.

I want to join, day and month and year, and it show me just month.

For example ; i join 5 Sep 1985. It show me just 1985's September calendar.

Anyone can help me ?

Recommended Answers

All 6 Replies

is it funny ?

i looked google, don't worry.

Could you post what you have done so far? In that way we'll know at what level you are at learning, and tailor a help for you.
Make sure you read the proper way of tagging code before hand.

#include <iostream>
using namespace std;
#include "stdlib.h"
void main ()

{
int year=1;
int yearstart=0;
int century=0;
int monthstart=0;
int endofweek=0;
int monthdays[]= {31,28,31,30,31,30,31,31,30,31,30,31};
int dayon[]= {1,1,1,1,1,1,1,1,1,1,1,1};
int month;
int currentyear;
int currentmonth;
int daysincalendaryearpriortocalendarmonth;
int daysinwholeyearssince1800;
int totalnumdays;
int daysinmonth;
int numblankdays=0;
int day;
int start;
int startday;


cout<<"Enter a year between 1800 & 2100 for the calendar you wish to produce"<<endl;
cin>>year;

if (year<1800 || year>2100)
 cout<<"not a valid year"<<endl;

cout<<"Enter the month of the calendar (1-12) you wish to produce"<<endl;
cin>>month;

if (month<0 || month>12)
 cout<<"not a valid month"<<endl;

if (month ==1)
 cout<<"            january,"<<" "<<year<<endl;
if (month ==2)
 cout<<"            february,"<<" "<<year<<endl;
if (month ==3)
 cout<<"            march,"<<" "<<year<<endl;
if (month ==4)
 cout<<"            april,"<<" "<<year<<endl;
if (month ==5)
 cout<<"            may,"<<" "<<year<<endl;
if (month ==6)
 cout<<"            june,"<<" "<<year<<endl;
if (month ==7)
 cout<<"            july,"<<" "<<year<<endl;
if (month ==8)
 cout<<"            august,"<<" "<<year<<endl;
if (month ==9)
 cout<<"           september,"<<" "<<year<<endl;
if (month ==10)
 cout<<"           october,"<<" "<<year<<endl;
if (month ==11)
 cout<<"           november,"<<" "<<year<<endl;
if (month ==12)
 cout<<"           december,"<<" "<<year<<endl;
 
cout<<"Sun"<<"   "<<"Mon"<<"   "<<"Tue"<<"   "<<"Wed"<<"   "<<"Thu"<<"   "<<"Fri"<<"   "<<"Sat"<<endl;
 
if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
  daysinmonth=31;
  
if (month==4 || month==6 || month==9 || month==11)
  daysinmonth=30;
  
if (month==2 & ((year % 400==0) || (year %4==0 && year % 100 !=0)))
  daysinmonth=29;
  
if (month==2 & ((year % 400!=0) || (year %4!=0 && year % 100 ==0)))
  daysinmonth=28;


 while (currentyear<year)
 {
 
  if ((year % 400==0) || (year %4==0 && year % 100 !=0))
      
   daysinwholeyearssince1800 += 366;
  else
   daysinwholeyearssince1800 += 365;
  
   currentyear++;

  } 


 currentmonth=1;




 while (currentmonth<month)
 {
 
  switch (currentmonth)
   {
    case 1: daysincalendaryearpriortocalendarmonth +=31;break;
    case 2: 
       if ((year % 400==0) || (year %4==0 && year % 100 !=0))
      
        daysinwholeyearssince1800 = 29;
       
       else
        
        daysinwholeyearssince1800 = 28;break;
    case 3: daysincalendaryearpriortocalendarmonth +=31;break;
    case 4: daysincalendaryearpriortocalendarmonth +=30;break;
    case 5: daysincalendaryearpriortocalendarmonth +=31;break;
    case 6: daysincalendaryearpriortocalendarmonth +=31;break;
    case 7: daysincalendaryearpriortocalendarmonth +=30;break;
    case 8: daysincalendaryearpriortocalendarmonth +=31;break;
    case 9: daysincalendaryearpriortocalendarmonth +=31;break;
    case 10: daysincalendaryearpriortocalendarmonth +=30;break;
    case 11: daysincalendaryearpriortocalendarmonth +=31;break;
    case 12: daysincalendaryearpriortocalendarmonth +=30;break;
   } 

 
   currentmonth++;
  } 
  
  
   totalnumdays=(daysinwholeyearssince1800 +daysincalendaryearpriortocalendarmonth);
   
   start=(daysinwholeyearssince1800 +
        daysincalendaryearpriortocalendarmonth + 3) % 7;


if (numblankdays==startday)
  day=1;
  
if (numblankdays!=startday)
  cout<<"  "<<"  "<<"  "<<"  "<<"  "<<"  "<<endl;
  
 
}

I can't write days..

This is the wrong forum for your code. There's a dedicated forum for C++. daysincalendaryearpriortocalendarmonth +=31; daysinwholeyearssince1800 += 366; what's in those variables before you add to them?

Well for the starting day. i guess you can do this.

First find this

int a = daysinwholeyearssince1800%7

According to this site

http://www.timeanddate.com/calendar/?year=1800

First january 1800 was a Wednesday ..

So if

string days[]={sun,mon,tue,wed,thurs,fri,sat};
//Then you can get the starting day with this 
int s =3+a;
//the starting day will be 
cout<<"The day of current month ="<< days[s];

I wrote this without compiling or testing. So pardon me if there are mistakes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.