Topic: 遇到奇怪的问题,请大家帮忙看看. |
Print this page |
1.遇到奇怪的问题,请大家帮忙看看. | Copy to clipboard |
Posted by: jasonwing27 Posted on: 2005-09-20 19:31 我写了一个程序.意图是输入conditionAOne , conditionATwo和conditionB 当conditionAOne , conditionATwo两个之中有一个为真的时候.条件A正确, 当conditionB为真的时候,条件B正确. 只有条件A,B都正确的时候,打印出"正确",否则打印"W" . 但是无论条件B是否正确,程序都会打印"正确" ,请大家帮忙看看. 奇怪的是我在条件B判断的时候,程序也会报出"条件B"错误. import java.io.* ; public class Jason { int conditionB = 0 ; String conditionAOne = "" ; String conditionATwo = "" ; BufferedReader in = new BufferedReader( new InputStreamReader (System.in) ) ; public static void main(String[] args) throws IOException { Jason rw = new Jason() ; rw.condition() ; rw.opinion() ; } public void condition() throws IOException { //条件A的判断 System.out.println( "请输入A条件1:" ) ; try{ conditionAOne = in.readLine() ; }catch(IOException e) { System.out.println("您输入的是:" + e.toString() + "条件A1错误"); } System.out.println( "请输入A条件2:" ) ; try{ conditionATwo = in.readLine() ; }catch(IOException e) { System.out.println("您输入的是:" + e.toString() + "条件A2错误"); } if( ((conditionAOne.compareTo("a")>=0 && conditionAOne.compareTo("z")<=0) || (conditionAOne.compareTo("A")>=0 && conditionAOne.compareTo("Z")<=0)) || ((conditionATwo.compareTo("a")>=0 && conditionATwo.compareTo("z")<=0) || (conditionATwo.compareTo("A")>=0 && conditionATwo.compareTo("Z")<=0)) ) { System.out.println("条件A正确!") ; } else System.out.println("条件A错误!") ; //条件B的判断 System.out.println( "请输入B条件:" ) ; try{ conditionB = Integer.parseInt(in.readLine()) ; if( conditionB >= 0 && conditionB <= 10 ) { System.out.println("条件B正确!") ; } else System.out.println("条件B错误!") ; }catch(NumberFormatException e) { System.out.println("条件B错误"); } } public void opinion() throws IOException { //只有A和B都为真才能打印正确 if( ((conditionAOne.compareTo("a")>=0 && conditionAOne.compareTo("z")<=0) || (conditionAOne.compareTo("A")>=0 && conditionAOne.compareTo("Z")<=0)) || ((conditionATwo.compareTo("a")>=0 && conditionATwo.compareTo("z")<=0) || (conditionATwo.compareTo("A")>=0 && conditionATwo.compareTo("Z")<=0)) || (conditionB >= 0 && conditionB <= 10)  System.out.println("正确!") ; else System.out.println("W!") ; } } |
2.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: why Posted on: 2005-09-20 19:39 Could you please use the old topic to continue this question?? Afterall you didn't have a meaningful subject line for all of these recent posts. 1. int conditionB = 0 ; 2. (conditionB >= 0 && conditionB <= 10) ==> 正确! Initialize conditionB to something out of the "正确" range. You don't have to post an image of the console, cut-n-pasting is fine. |
3.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: jasonwing27 Posted on: 2005-09-20 19:48 首先谢谢能看我的问题,但是我英文不好,你能给我讲明白点吗?谢谢 说中文.谢谢.能不能给我指出怎么解决问题的方法啊. |
4.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: jasonwing27 Posted on: 2005-09-20 20:16 WHY ,我知道想下面这样写就可以了,但是我就是想弄明白上面那么写为什么错了. import java.io.* ; public class Jason { int conditionB = 120 ; String conditionAOne = "" ; String conditionATwo = "" ; boolean a ; boolean b ; BufferedReader in = new BufferedReader( new InputStreamReader (System.in) ) ; public static void main(String[] args) throws IOException { Jason rw = new Jason() ; rw.condition() ; rw.opinion() ; } public void condition() throws IOException { //条件A的判断 System.out.println( "请输入A条件1:" ) ; try{ conditionAOne = in.readLine() ; }catch(IOException e) { System.out.println("您输入的是:" + e.toString() + "条件A1错误"); } System.out.println( "请输入A条件2:" ) ; try{ conditionATwo = in.readLine() ; }catch(IOException e) { System.out.println("您输入的是:" + e.toString() + "条件A2错误"); } if( ((conditionAOne.compareTo("a")>=0 && conditionAOne.compareTo("z")<=0) || (conditionAOne.compareTo("A")>=0 && conditionAOne.compareTo("Z")<=0)) || ((conditionATwo.compareTo("a")>=0 && conditionATwo.compareTo("z")<=0) || (conditionATwo.compareTo("A")>=0 && conditionATwo.compareTo("Z")<=0)) ) { System.out.println("条件A正确!") ; a = true ; } else{ System.out.println("条件A错误!") ; a = false ; } //条件B的判断 System.out.println( "请输入B条件:" ) ; try{ conditionB = Integer.parseInt(in.readLine()) ; if( conditionB >= 0 && conditionB <= 10 ) { System.out.println("条件B正确!") ; b = true ; } else{ System.out.println("条件B错误!") ; b = false ; } }catch(NumberFormatException e) { System.out.println("条件B错误"); } } public void opinion() throws IOException { //只有A和B都为真才能打印正确 if( a&&b ) System.out.println("正确!") ; else System.out.println("W!") ; } } |
5.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: why Posted on: 2005-09-20 20:22 b is initialized to false by default. conditionB = Integer.parseInt(in.readLine()) ; in.readLine() returns "e", NumberFormatException is thrown and caught by }catch(NumberFormatException e) { System.out.println("条件B错误"); } b is still false 1. int conditionB = 0 ; 2. (conditionB >= 0 && conditionB <= 10) ==> 正确! 這不算是英文吧 解决问题的方法已經說得清楚 > Initialize conditionB to something out of the "正确" range. Initialize 不可能不懂(否則無謂編程了),something 也是 out of the "正确" range == 在(閣下設定,所謂)"正确"範圍之外 假如閣下這句也看不懂或不願意花一點兒工夫看懂,那就算了 閣下可能在想:回答一句便成,幹啥要囉裡囉囌教訓人吧 放心,敝人覺得已盡了力,不會再煩閣下了 不過,下趟閣下再有這種標題不明確的帖子,敝人會毫不客氣地删除的... 请帮忙回答这个菜鸟问题 小弟刚开始学,有2个题目不会 菜鸟问题,请高手解答 跪求解答菜鸟问题 程序有问题,请各位帮忙解答 不知道是什么原因错了 想知道哪里错了 谢谢,大家帮忙看看 出个题目,看谁能解答。 小弟初学JAVA,请教两个问题,请大家帮忙 高手能给个例子吗? 写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! 遇到奇怪的问题 |
6.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: jasonwing27 Posted on: 2005-09-20 23:14 我觉得你很奇怪,我对你说话一直都很客气,不明白你为什么说话这么挖苦人。 也没有人对我说过帖子的题目该怎么写,我只是见很多人这么写了,才这么写,如果你觉得这样不行,你可以告诉我,我又不会反驳什么,何必这么说话呢? |
7.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: why Posted on: 2005-09-20 23:27 I wrote the following on your posts: (and edited your topics to add certain more appropiate subjects in brackets for the first few times.) 请帮忙回答这个菜鸟问题。(main方法有什么作用?各参数有什么用途?代表什么含义?) http://www.cjsdn.net/post/view?bid=1&id=110543&sty=3 { 请尽量用准确的文字描述作为标题 这个问题……应该自己先看书,看不明白再问。 } 小弟刚开始学,有2个题目不会。(计算e=1+1/1!+1/2!+…+1/n!) http://www.cjsdn.net/post/view?bid=1&id=110544&sty=3 菜鸟问题,请高手解答 (cannot resolve symbol: JOptionpane) http://www.cjsdn.net/post/view?bid=1&id=116136&sty=3 { 请尽量用准确的文字描述作为标题 you should cut-and-paste from the command window, instead of using an image! } 不知道是什么原因错了(BaseClass ; 的分号有错误) http://www.cjsdn.net/post/view?bid=1&id=119518&sty=3 { 请尽量用准确的文字描述作为标题 } 写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! http://www.cjsdn.net/post/view?bid=1&id=156606 You should have continued to use the topic 请教判断语句 to post this question. Do you want more? Take a look at the topics you posted -- you could find a list in your own Profile page. Did you ever read what I wrote? I'm just tired of all these. Is it clear enough? I don't know whether you would try to understand what I mentioned in this post, but you should certainly read this: 言尽于此 |
8.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: jasonwing27 Posted on: 2005-09-20 23:46 那些问题,我看没有人回答就没有看,当然不知道里面你对我说的话了,好,这是我的错,我道歉,我只是不明白我只是在问问题,你有必要针对我这样吗? 我对你说话一直都很客气的,你解答我的每个问题,我都会说谢谢,感谢你。 我不是讨厌你说英文,但是我一看英文就头大。 如果你觉得不会不能问得话,我就不说什么了。 |
9.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: why Posted on: 2005-09-21 00:00 jasonwing27 wrote: 閣下要睜著眼說謊,敝人也沒有辦法 上面列舉的話題哪一個没有人回答! 真是豈有此理! 如果閣下還不知道問題所在,對不起,敝人只能表示遺憾! 很坦白說,客氣有個屁用! 敝人從來不著意一句謝謝半句感謝,CJSDN這裡要的是交流,希望的是大夥兒成長,壯大中華民族的Java力量. 唉-- 再坦白一點說,如果敝人的公司有閣下那様表現的人,縱使有點基本的禮貌,還是會一腳攆走,讓他在另外的領域有所發展,前程萬里. |
10.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: ranchgirl Posted on: 2005-09-21 02:58 Thanks WHY! Ignore such post, don't argue with him/her, save your time, save your angryness, save your life, ... Smile... |
11.Re:遇到奇怪的问题,请大家帮忙看看. [Re: gongshi] | Copy to clipboard |
Posted by: why Posted on: 2005-09-21 05:57 gongshi版主: 敝人沒有真的動氣,這一次長篇地那些毛病羅列出來,只是讓大夥兒知道我們當版主的,管理一個版面有多忙. 有時驟眼看看一兩個留言,可能會覺得管理人暴躁,尖刻刁難,恃權凌人,但或許背後卻大有文章. 那些查證的工夫其實很費神,希望新人尊重自己的問題,努力做好自己的本分:先好好讀讀書,再嘗試搜尋一下相關的舊討論,那麼真有問題,也自然會是具體的疑問,而不是懶人的求救;又因為有己一定的背境知識,提問自然會比較清晰. |
12.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: ranchgirl Posted on: 2005-09-21 08:12 尊敬的WHY阁下: 您的脾气真好! 佩服!佩服! 敝人功夫修养都不够,在此学习! 谢谢! ===================== PS. Hehe. 九牛二虎之力 spent, take a break. |
13.java与SQL的连接问题. [Re: gongshi] | Copy to clipboard |
Posted by: cxy123884 Posted on: 2005-09-21 08:18 装好了驱动程序,也设制好了CLASSPATH路径(.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;E:\classes;D:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib;D:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;D:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;D:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlerver.jar;%JAVA_HOME%\jre). 抄了个小程序,访问数据库. 系统说没有这样的包.注释掉它后运行. 结果异常:java.lang.ClassNotFoundException:com.microsoft.jdbc.sqlserver.SQLServerDriver 请问我该怎么做? 错在哪里? |
14.Re:遇到奇怪的问题,请大家帮忙看看. [Re: why] | Copy to clipboard |
Posted by: zcjl Posted on: 2005-09-21 09:03 why wrote: 每次看到WHY不厌其烦的修改那些表述不明的标题,回答那些重复的问题,真是佩服得不行 |
15.Re:java与SQL的连接问题. [Re: cxy123884] | Copy to clipboard |
Posted by: why Posted on: 2005-09-21 11:09 cxy123884 wrote: 小程序? Is it applet? |
16.Re:遇到奇怪的问题,请大家帮忙看看. [Re: jasonwing27] | Copy to clipboard |
Posted by: jasonwing27 Posted on: 2005-09-21 12:10 好的,我会注意的,只是不希望你说话那么刻薄,交流也没有必要说话刻薄对不对. |
17.Re:遇到奇怪的问题,请大家帮忙看看. [Re: why] | Copy to clipboard |
Posted by: 空心菜 Posted on: 2005-09-21 23:25 why wrote: 所谓理解万岁 如果大家都能相互理解 我想,这世界会更每好 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |