• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
???!!!
博客园    首页    新随笔    联系   管理    订阅  订阅
java基础练习 13
import java.util.Scanner;
public class Thirtheen {
/*输入某年某月某日,判断这一天是这一年的第几天?*/
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int sum,i;
System.out.print("请输入年份:");
int a=input.nextInt();
System.out.print("\n");
System.out.print("请输入月份:");
int b=input.nextInt();
System.out.print("\n");
System.out.print("请输入日:");
int c=input.nextInt();
System.out.print("\n");

if(a%4==0&&a%100!=0&&b>1)
sum=29;
else if(b>1)
sum=28;
else
sum=0;
for(i=1;i<b;i++){
if(i==2)
continue;
switch(i){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
sum=sum+31;
case 4: case 6: case 9: case 11: 
sum=sum+30;

}
}
sum=sum+c;
System.out.println("到"+a+"年"+b+"月"+c+"日"+","+a+"年过去了"+sum+"天");

}

}

  

posted on 2017-01-26 23:27  ???!!!  阅读(281)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3