# Thread: Calendar did not run correctly

1. ## Calendar did not run correctly

The calendar does not show all 12 month, the output only show the name of the month and the input of the year... how to solve it???
or i need to create a loop in switch????

Code:
```#include <iostream>
#include <string>

using namespace std;

int main()
{
int year, day_code, leap_year;
int y1, y2, y3;
int hari_dalam_bulan, hari, bulan;
bool amik = false;

cout << " Enter year for the calendar : " ;

cin >> year;

y1 = (year - 1)/4;
y2 = (year - 1)/100;
y3 = (year - 1)/400;

day_code = (year + y1 + y2 + y3) %7;

if( year%4==0 && year%100!=0 || year%400==0 )

amik = true;

else

amik = false;

cout << "                   " ;

for ( bulan = 1; bulan <=12; bulan++ )
{
switch(bulan)
{

case 1 : cout << "\n\nJanuary                     " << year;
hari_dalam_bulan = 31;
break;

case 2 : cout << "\n\nFebruary                    " << year;
hari_dalam_bulan = leap_year ? 29:28;
break;

case 3 : cout << "\n\nMarch                       " << year;
hari_dalam_bulan = 31;
break;

case 4 : cout << "\n\nApril                       " << year;
hari_dalam_bulan = 30;
break;

case 5 : cout << "\n\nMay                         " << year;
hari_dalam_bulan = 31;
break;

case 6 : cout << "\n\nJune                        " << year;
hari_dalam_bulan = 30;
break;

case 7 : cout << "\n\nJuly                        " << year;
hari_dalam_bulan = 31;
break;

case 8 : cout << "\n\nAugust                      " << year;
hari_dalam_bulan = 31;
break;

case 9 : cout << "\n\nSeptember                   " << year;
hari_dalam_bulan = 30;
break;

case 10: cout << "\n\nOctober                     " << year;
hari_dalam_bulan = 31;
break;

case 11: cout << "\n\nNovember                    " << year;
hari_dalam_bulan = 30;
break;

case 12: cout << "\n\nDecember                    " << year;
hari_dalam_bulan = 31;
break;

}
}
day_code = ( day_code + hari_dalam_bulan ) % 7;

cout << "\n\nSun  Mon  Teu  Thu Fri Sat Sun\n" ;

for ( hari=1 ; hari<= 1 + day_code * 5; hari++ )
cout << " ";

for ( hari=1 ; hari<= hari_dalam_bulan; hari++ )
{
cout <<  hari;

if ((hari + day_code) % 7 > 0)
cout << "   ";

else
cout << "\n ";
}

cout << year << day_code;

system ("pause");
return 0;

}```

2. Format your code better and you would see that you're braces are lined up incorrectly. You want the for loop
Code:
`for ( bulan = 1; bulan <=12; bulan++ )`
to encompass the whole program up until
Code:
`cout << year << day_code;`
Also, I'd like to mention that your output is just as poorly formatted as your code. Your week also doesn't contain wednesday.