100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > java程序获取某年某月的天数

java程序获取某年某月的天数

时间:2022-10-21 06:55:32

相关推荐

java程序获取某年某月的天数

package zuoye;import java.util.Scanner;public class Ts1 {public static void main(String[] args) {// TODO Auto-generated method stubSystem.out.print("请输入年份:"); Scanner s= new Scanner(System.in);int a=s.nextInt();boolean year;System.out.print("请输入月份:"); Scanner s1= new Scanner(System.in);int b=s.nextInt();int [] arr={0,31,28,31,30,31,30,31,31,30,31,30,31};if(((a%4==0)&(a%100!=0))|(a%400==0)){year=true;System.out.println("闰年");arr[2]++;}else{year=false;System.out.println("平年");}switch(b){ case 1: ;break;case 3: ;break;case 5: ;break;case 7: ;break;case 8: ;break;case 10: ;break;case 12:System.out.println(a+"年的"+b+"月有"+arr[b]+"天"); ;break;case 4: ;break;case 6: ;break;case 9: ;break;case 11:System.out.println(a+"年的"+b+"月有"+arr[b]+"天"); ;break;case 2: System.out.println(a+"年的"+b+"月有"+arr[b]+"天"); ;break;default:System.out.println("月份出错");}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。