Topic: 写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~!

  Print this page

1.写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! Copy to clipboard
Posted by: jasonwing27
Posted on: 2005-09-18 14:56

import java.io.* ;
public class Jason {

  public static void main(String[] args) throws IOException {
    int conditionB = 0 ;
    String conditionAOne = "" ;
    String conditionATwo = "" ;

    BufferedReader in = new BufferedReader( new InputStreamReader (System.in) ) ;    
    
    Jason rw = new Jason() ;
    rw.condition() ;
    
  }

  public void condition(){
    System.out.println( "请输入A条件1:" ) ;
conditionAOne = in.readLine() ;
System.out.println( "请输入A条件2:" ) ;
conditionATwo = in.readLine() ;
    System.out.println( "请输入B条件:" ) ;
    conditionB = Integer.parseInt(in.readLine()) ;

    if( ((conditionAOne >= "a" && conditionAOne<="z") || (conditionAOne >= "A" && conditionAOne<="Z")) ||
      ((conditionATwo >= "a" && conditionATwo<="z") || (conditionATwo >= "A" && conditionATwo<="Z")) )
      
     System.out.println("r") ;
    else
System.out.println("w") ;

    if( conditionB >= "0" && conditionB <= "100" )
      System.out.println("r2") ;
    else
      System.out.println("w2") ;
  }

}

2.Re:写的程序出错了,想不通该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: jasonwing27] Copy to clipboard
Posted by: why
Posted on: 2005-09-18 20:48

The comparison operators, i.e., ==, >=, >, <, etc., don't work with String, you may want to use String's equals() and compareTo() methods (and the variants).

You should have continued to use the topic 请教判断语句 to post this question.
As I mentioned in this post, you may have to do the comparison character-by-character.

知道 学的不好 就找本書好好讀讀,
如果真的看不懂,想不通,就不要再看,想通應否放棄學習編程--
人人各有專長,何必把時間浪費於不適合自己,力不從心的事情上?

3.Re:写的程序出错了,想不通该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: why] Copy to clipboard
Posted by: ranchgirl
Posted on: 2005-09-18 22:49

why wrote:
如果真的看不懂,想不通,就不要再看,想通應否放棄學習編程--
人人各有專長,何必把時間浪費於不適合自己,力不從心的事情上?


I cannot agree more!!!

gongshi wrote:
In education, there is a famous saying:

"The question is not how smart you are, but how you are smart."

In Chinese, it probably means, "问题不在於你是否聪明,而是你在哪方面聪明。"

Finding out where and on what your talent is, that is very important and benificial to your life and future.

Not everyone can be a good programmer. However, everyone can be good on something you really good at.

Find that out, and smile!

Good luck to your future!

Copied from my post here
http://bbs.chinajavaworld.com/post/view?bid=20&id=660344&sty=1&tpg=1&age=0&ppg=1

4.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: jasonwing27] Copy to clipboard
Posted by: jasonwing27
Posted on: 2005-09-18 23:47

问题儿童,如果你不想解答我的问题,你可以不说话,我是学的不好,但是我是在努力,这个又不是什么作业,难道我有问题就不能问吗?
如果是这个样子,这个论坛还开它干什么啊?
你会就可以鄙视别人吗?

5.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: jasonwing27] Copy to clipboard
Posted by: why
Posted on: 2005-09-19 00:50

jasonwing27 wrote:
问题儿童,如果你不想解答我的问题,你可以不说话,我是学的不好,但是我是在努力,这个又不是什么作业,难道我有问题就不能问吗?
如果是这个样子,这个论坛还开它干什么啊?
你会就可以鄙视别人吗?

提示已經在上面和"请教判断语句"給閣下。
閣下當然可以問,但把這一段code丟出來有甚麼意思?--除了讓大家知道閣下學得一塌糊塗之外... I'm serious.

如果閣下還是想不通,而又不肯好好讀讀書學好基礎,那麼
閣下根本不適合繼續編程!

不是鄙視,而是誠懇地勸閣下好好想一想努力的方向,世事往往徒勞無功的。
請記住gongshi引的那句話:问题不在於你是否聪明,而是你在哪方面聪明。

敲中文字實在辛苦...
I have reviewed your profile before I wrote so -- I did do some work before I made the suggestions.
You have been asking beginner's questions since last Sept, and I don't think your skills have improved -- you are still asking trivial questions that one could easily learn from any introductory book on Java.
Maybe you don't understand the hints I provided...

6.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: why] Copy to clipboard
Posted by: ranchgirl
Posted on: 2005-09-19 02:11

why wrote:
敲中文字實在辛苦...


Yes, I know...

苦口婆心, 真是热心人...

But, please remember this statement by someone else
http://bbs.chinajavaworld.com/post/view?bid=18&id=464233&sty=1&tpg=1&age=-1
"一个人改变自己都那么难,你还想改变别人?
Please ignore....

7.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: why] Copy to clipboard
Posted by: liang
Posted on: 2005-09-20 23:12

why wrote:
I have reviewed your profile before I wrote so -- I did do some work before I made the suggestions.
You have been asking beginner's questions since last Sept

不愧是元老,敬佩的说!

8.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: jasonwing27] Copy to clipboard
Posted by: jinger
Posted on: 2005-09-21 09:26

敲中文字實在辛苦...
敲中英文字也實在辛苦...

靠你起挖 日语发音
意思是:
你好早安
呵呵
以后得向元老请教呀

9.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: jasonwing27] Copy to clipboard
Posted by: 什么头
Posted on: 2005-09-22 10:19

看起来像……javascript当然,如果你入行早,叫livescript我也没意见……

10.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: jasonwing27] Copy to clipboard
Posted by: wuyoubei1
Posted on: 2005-09-22 16:08

所有的问题都自己解决了,还问你们干什么。发出来把错误给大家看,让众人共同提高,这难道不是开论坛的目的吗,编程只靠一个人的力量怎么行的通。

11.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: jasonwing27] Copy to clipboard
Posted by: wuyoubei1
Posted on: 2005-09-22 16:12

敲中文字實在辛苦...

这网站是谁开的,找个不怕 “敲中文字實在辛苦...” 的人来解决问题,好不。

12.Re:写的程序出错了,想不同该怎么改,我学的不好,请高手帮忙!谢谢~! [Re: wuyoubei1] Copy to clipboard
Posted by: bluecrystal
Posted on: 2005-09-22 17:07

wuyoubei1 wrote:
敲中文字實在辛苦...

这网站是谁开的,找个不怕 “敲中文字實在辛苦...” 的人来解决问题,好不。


拜托,论坛本来就是一个没有谁强迫谁必须回答或者不回答的地方
你有权力发问,但别人也有选择不回答的权利
这里本来就是一个大家共享,交流的自由场所
没有强迫性哈

btw 你的程序代码里面,有如下几处错误:
1 main里面定义的conditionAOne、conditionATwo、conditionB怎么能直接在另外一个函数condition()里面用呢?如果你非要在这几个函数里面公用变量,那也得放在类里面吧,而且静态函数里面调用非静态成员变量也是有规定的,看书;
2 第二个,如why所说,java的字符串比较不能单纯的用><=之类的来完成,而应该用String这个类提供的函数;
。。。。。


   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