码迷,mamicode.com
首页 > 其他好文 > 详细

HW4.28

时间:2016-08-18 22:57:00      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

技术分享

 

 1 import java.util.Scanner;
 2 
 3 public class Solution
 4 {
 5     public static void main(String[] args)
 6     {
 7         Scanner input = new Scanner(System.in);
 8 
 9         System.out.print("Enter the year: ");
10         int year = input.nextInt();
11         System.out.print("Enter the weekday: ");
12         int weekDay = input.nextInt();
13 
14         input.close();
15 
16         String[] monthString = {"January", "February", "March", "April", "May", "June", 
17                 "July", "August", "September", "October", "November", "December"};
18 
19         int[] dayOfMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
20 
21         String[] dayOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
22 
23         if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
24             dayOfMonth[1]++;
25 
26         for(int i = 0; i < 12; i++)
27         {
28             System.out.println(monthString[i] + " 1, " + year + " is " + dayOfWeek[weekDay]);
29             weekDay = (weekDay + dayOfMonth[i]) % 7;
30         }
31     }
32 }

 

HW4.28

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5785383.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!