标题:JAVA新手求助,看看哪里错了
取消只看楼主
男孩的诗
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-4-1
结帖率:50%
已结贴  问题点数:20 回复次数:1 
JAVA新手求助,看看哪里错了
输出星期的代码,求大神指点!!
public class Weekend {
     public static void main(String args[])
  {
        String stringNumber;String week="";
        int number = 0;
        while(number<1||number>7)  {
             stringNumber = JOptionPane.showInputDialog( "输入一个数(1---7)");
             number = Integer.parseInt( stringNumber );
      }
        switch(number)
  {           case 1 :   week ="星期一";break;
              case 2 :   week ="星期二";break;
              case 3 :   week ="星期三";break;
              case 4 :   week ="星期四";break;
              case 5 :   week ="星期五";break;
              case 6 :   week ="星期六";break;
              case 7 :   week ="星期日";break;      
      }
      JOptionPane.showMessageDialog( null,"星期是:"+week,"结果",JOptionPane.PLAIN_MESSAGE);
      System.exit(0);
  }
}      


报错:

--------------------Configuration: Java <Default>--------------------
D:\JCreator Pro\MyProjects\FindMax\weekend\Weekend.java:7: 找不到符号
符号: 变量 JOptionPane
位置: 类 Weekend
             stringNumber = JOptionPane.showInputDialog( "输入一个数(1---7)");
                            ^
D:\JCreator Pro\MyProjects\FindMax\weekend\Weekend.java:19: 找不到符号
符号: 变量 JOptionPane
位置: 类 Weekend
      JOptionPane.showMessageDialog( null,"星期是:"+week,"结果",JOptionPane.PLAIN_MESSAGE);
                                                           ^
D:\JCreator Pro\MyProjects\FindMax\weekend\Weekend.java:19: 找不到符号
符号: 变量 JOptionPane
位置: 类 Weekend
      JOptionPane.showMessageDialog( null,"星期是:"+week,"结果",JOptionPane.PLAIN_MESSAGE);
      ^
3 错误

Process completed.
搜索更多相关主题的帖子: public number JAVA 
2014-04-01 18:52
男孩的诗
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-4-1
得分:0 
回复 3楼 zjcl817
谢谢 ,知道了。能再请教一个程序么?
又写了一个程序:100——1000的水仙花数
 public class Shuixianhuashu
   {
       public static void main(String args[]);
       {
         int b1 , b2 , b3;
           for( int m = 101;m<1000;m++)
            {
                b3 = m/100;
                b2 = m%100/10;
                b1 = m%10;
                if( (b3*b3*b3*+b2*b2*b2+b1*b1*b1) ==m)
                  {
                      System.out.println(m+"是一个水仙花数");
                 }
            }
        }
}            


报错:

--------------------Configuration: Java <Default>--------------------
D:JCreator ProMyProjectsFindMaxweekendWeekend.java:1: 类 Shuixianhuashu 是公共的,应在名为 Shuixianhuashu.java 的文件中声明
 public class Shuixianhuashu
        ^
D:JCreator ProMyProjectsFindMaxweekendWeekend.java:3: 缺少方法主体,或声明抽象
       public static void main(String args[]);
                          ^
2 错误

Process completed.
2014-04-02 12:18



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-429529-1-1.html




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

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