显示一年的日历

import javax.swing.*;

public class xin{

   

    public static void main(String[] args) {

        String year1=JOptionPane.showInputDialog("Enter a year");

        int year=Integer.parseInt(year1);

        String day1=JOptionPane.showInputDialog("Today is");

        int day=Integer.parseInt(day1);

        int []month_day={31,28,31,30,31,30,31,31,30,31,30,31};

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

            month_day[1]=29;

        String []weekend={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};

        String []month={"January","February","March","April","May","June","July","August","September","October","November","December"};

        for(int j=0;j<12;j++)

        {

            System.out.println("                        "+month[j]+"   "+year);

            System.out.println("       ---------------------------------------------------------------");

            for(int i=0;i<7;i++)

                System.out.printf("%10s",weekend[i]);

            System.out.println();

            day=day%7;

            for(int y=0;y<day;y++)

                System.out.print("          ");

            for(int t=0;t<month_day[j];t++)

            {

                System.out.printf("%10d",t+1);

                day++;

                if(day%7==0)

                    System.out.println();

                   

            }

            System.out.println();

       

        }

       

       

       

    }

}

 

 

 

转载于:https://www.cnblogs.com/-wang-xin/archive/2012/09/21/2697028.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值