| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 496 人关注过本帖
标题:这个程序的问题出在哪
取消只看楼主 加入收藏
川云漠漠
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2014-10-8
结帖率:57.89%
收藏
已结贴  问题点数:5 回复次数:0 
这个程序的问题出在哪
package com.imooc;
import java.util.Scanner;
public class home {
                Scanner input=new Scanner(System.in);
        System.out.println("请输入年份:");
        double year=input.nextDouble();
        System.out.println("请输入月份:");
        double month=input.nextDouble();
        System.out.println("请输入第几天:");
        double day=input.nextDouble();
        if(month==1){
            month=13;
            year--;
        }
        if(month==2){
            month=14;
            year--;
        }
        if(month==13||month==3||month==5||month==7||month==8||month==10||month==12){
            int q=31;
             double m=month;
                double j=year/100+1;
                double k=year%100;
                double h=((q+2.6*(m+1)+k+k/4+j/4+5*j)%7+2);
                if(h==0)
                    System.out.println("星期六!");
                else if(h==1)
                    System.out.println("星期天!");
                else if(h==2)
                    System.out.println("星期一!");
                else if(h==3)
                    System.out.println("星期二!");
                else if(h==4)
                    System.out.println("星期三!");
                else if(h==5)
                    System.out.println("星期四!");
                else
                    System.out.println("星期五!");
        }
        if(month==4||month==6||month==9||month==11){
          double q=30;
          double m=month;
            double j=year/100;
            double k=year%100;
            int b=(int)(q+2.6*(m+1)+k+k/4+j/4+5*j);
            int h=(b%7);
            if(h==0)
                System.out.println("星期六!");
            else if(h==1)
                System.out.println("星期天!");
            else if(h==2)
                System.out.println("星期一!");
            else if(h==3)
                System.out.println("星期二!");
            else if(h==4)
                System.out.println("星期三!");
            else if(h==5)
                System.out.println("星期四!");
            else
                System.out.println("星期五!");
        }
        if(month==14){
            if((year%4==0&&year%100!=0)||year%400==0){
                double q=29;
                 double m=month;
                    double j=year/100+1;
                    double k=year%100;
                    double  h=((q+2.6*(m+1)+k+k/4+j/4+5*j)%7);
                    if(h==0)
                        System.out.println("星期六!");
                    else if(h==1)
                        System.out.println("星期天!");
                    else if(h==2)
                        System.out.println("星期一!");
                    else if(h==3)
                        System.out.println("星期二!");
                    else if(h==4)
                        System.out.println("星期三!");
                    else if(h==5)
                        System.out.println("星期四!");
                    else
                        System.out.println("星期五!");
            }
            else{
                double q=28;
                 double m=month;
                    double j=year/100+1;
                    double k=year%100;
                    double  h=((q+2.6*(m+1)+k+k/4+j/4+5*j)%7);
                    if(h==0)
                        System.out.println("星期六!");
                    else if(h==1)
                        System.out.println("星期天!");
                    else if(h==2)
                        System.out.println("星期一!");
                    else if(h==3)
                        System.out.println("星期二!");
                    else if(h==4)
                        System.out.println("星期三!");
                    else if(h==5)
                        System.out.println("星期四!");
                    else
                        System.out.println("星期五!");
            }
        }
    }
}
ps:这个程序可以执行,但是执行出来的结果与事实不符,请问问题出在哪?
搜索更多相关主题的帖子: package public double import 
2014-11-04 12:59
快速回复:这个程序的问题出在哪
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019878 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved