| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 534 人关注过本帖
标题:小问题,可就是不明白,呵呵,菜鸟不要见怪啊。
只看楼主 加入收藏
wewoor
Rank: 1
等 级:新手上路
帖 子:25
专家分:5
注 册:2010-10-4
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:2 
小问题,可就是不明白,呵呵,菜鸟不要见怪啊。
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class Test_ extends JFrame{
     public static void main(String arg[]){
         Test B=new Test();
         B.Fn();
         
     }
     void Fn(){
         String str=JOptionPane.showInputDialog("请输入你的成绩:");
         int a=Integer.parseInt(str);

         if (a>=60&&a<80)
              JOptionPane.showMessageDialog(this,"恭喜你及格了!,继续加油!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if (a>=80&&a<100);
          JOptionPane.showMessageDialog(this,"very good!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if (a<60&&a>40||a==40)
             JOptionPane.showMessageDialog(this,"you need to study hard!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if(a<40||a==40)
             JOptionPane.showMessageDialog(this,"hope you to have a good attitude","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if(a>100)
             JOptionPane.showMessageDialog(this,"error","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         
     }     
         
 
}



当我输入12时,它为什么还会弹出very good 啊?
搜索更多相关主题的帖子: void 100 public import 
2010-11-24 17:34
funword
Rank: 2
等 级:论坛游民
帖 子:17
专家分:14
注 册:2010-9-26
收藏
得分:0 
你把Fn()里的代码换成下面的代码试试:
程序代码:
void Fn(){
         String str=JOptionPane.showInputDialog("请输入你的成绩:");
         int a=Integer.parseInt(str);

         if (a>=60&&a<80)//我只改了判断条件,
              JOptionPane.showMessageDialog(this,"恭喜你及格了!,继续加油!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if (a>=80&&a<=100);
          JOptionPane.showMessageDialog(this,"very good!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if (a<60&&a>=40)
             JOptionPane.showMessageDialog(this,"you need to study hard!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if(a<40&&a>=0)
             JOptionPane.showMessageDialog(this,"hope you to have a good attitude","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if(a>100||a<0)
             JOptionPane.showMessageDialog(this,"error","成绩情况",JOptionPane.INFORMATION_MESSAGE);
        
     }     

我只改了判断条件
2010-11-25 13:01
思忆季节
Rank: 2
来 自:珠海
等 级:论坛游民
帖 子:42
专家分:62
注 册:2010-5-12
收藏
得分:20 
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class Test_ extends JFrame{//应该是Test吧??
     public static void main(String arg[]){
         Test B=new Test();
         B.Fn();
         
     }
     void Fn(){
         String str=JOptionPane.showInputDialog("请输入你的成绩:");
         int a=Integer.parseInt(str);
         if (a>=60&&a<80)
              JOptionPane.showMessageDialog(this,"恭喜你及格了!,继续加油!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if (a>=80&&a<100);//多加了一小分号
          JOptionPane.showMessageDialog(this,"very good!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if (a<60&&a>40||a==40)
             JOptionPane.showMessageDialog(this,"you need to study hard!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if(a<40||a==40)
             JOptionPane.showMessageDialog(this,"hope you to have a good attitude","成绩情况",JOptionPane.INFORMATION_MESSAGE);
         if(a>100)
             JOptionPane.showMessageDialog(this,"error","成绩情况",JOptionPane.INFORMATION_MESSAGE);         
     }            
}
//以下我的建议,请见谅哦哦
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class Test extends JFrame{
     public static void main(String arg[]){
         Test B=new Test();
         B.Fn();
         
     }
     void Fn(){
         String str=JOptionPane.showInputDialog("请输入你的成绩:");
         int a=Integer.parseInt(str);

         if (a>=60&&a<80){
            JOptionPane.showMessageDialog(this,"恭喜你及格了!,继续加油!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
            }
         else if (a>=80&&a<100){
        JOptionPane.showMessageDialog(this,"very good!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
        }
         else if (a<60&&a>40){
           JOptionPane.showMessageDialog(this,"you need to study hard!","成绩情况",JOptionPane.INFORMATION_MESSAGE);
           }
         else if(a<=40&&a>=0){
           JOptionPane.showMessageDialog(this,"hope you to have a good attitude","成绩情况",JOptionPane.INFORMATION_MESSAGE);
           }
         else{
           JOptionPane.showMessageDialog(this,"error","成绩情况",JOptionPane.INFORMATION_MESSAGE);
           }
         
     }
2010-11-25 14:15
快速回复:小问题,可就是不明白,呵呵,菜鸟不要见怪啊。
数据加载中...
 
   



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

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