code above would print first month correct. but from the second month days or not in order.
import java.io.*;
public class calendertest {
public static void main(String[] args) {
int months=12;
int days=0;
int i=0;
for(months=1;months<=12;months++)
{
System.out.println("----------------------");
if(months%2==1)
{
for(days=0;days<=31;days++)
{
if (days%7==1)
System.out.println("sunday-"+days);
else if(days%7==2)
System.out.println("monday-"+days);
else if(days%7==3)
System.out.println("tuesday-"+days);
else if(days%7==4)
System.out.println("wedday-"+days);
else if(days%7==5)
System.out.println("thursday-"+days);
else if(days%7==6)
System.out.println("friday-"+days);
else if(days%7==0)
System.out.println("saturday-"+days);
}
System.out.println('\n');
}
System.out.println("----------------------");
if(months%2==0)
{
for(days=0;days<=30;days++)
{
if (days%7==1)
System.out.println("sunday-"+days);
else if(days%7==2)
System.out.println("monday-"+days);
else if(days%7==3)
System.out.println("tuesday-"+days);
else if(days%7==4)
System.out.println("wedday-"+days);
else if(days%7==5)
System.out.println("thursday-"+days);
else if(days%7==6)
System.out.println("friday-"+days);
else if(days%7==0)
System.out.println("saturday-"+days);
}
}
}
}
}