各位朋友帮忙看一下,我是个Java新手,我写的程序好像在循环部分有点问题,那位能帮我调试一下啊!!
我先在这里谢过了代码如下:
package test;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;class shanchu  {
     public static void main(String[] args){
         tiao_shi: for(;;){
         double ww;
         double qq;
         double rr;
         BufferedReader obg_reader=new BufferedReader(new InputStreamReader(System.in));
         System.out.println("请输入你的数字");
         try{
             ww = new Double(obg_reader.readLine()).doubleValue();
             System.out.println("请再次输入你的数字");
             qq = new Double(obg_reader.readLine()).doubleValue();
             System.out.println(ww + "+" + qq + "=" + (ww + qq));
             }catch(IOException e){}
             System.out.println("是否继续输入y或Y");
      try{
      rr = new Double(obg_reader.readLine()).doubleValue();
     if(rr=='y' || rr=='Y'){
      continue tiao_shi;
     }
    else{
     break tiao_shi;
        }
       }catch(IOException e){}         }
     }
}

解决方案 »

  1.   

    package test;import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;class shanchu
    {
    public static void main(String[] args)
    {
    while(true)
    {
    double ww;
    double qq;
    String rr;

    try
    {
    BufferedReader obg_reader = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("请输入你的数字");
    ww = new Double(obg_reader.readLine()).doubleValue();
    System.out.println("请再次输入你的数字");
    qq = new Double(obg_reader.readLine()).doubleValue();
    System.out.println(ww + "+" + qq + "=" + (ww + qq));
    System.out.println("是否继续输入y或Y");
    rr = obg_reader.readLine();
    if ( rr.equalsIgnoreCase("y") )
    {

    }
    else
    {
    return;
    }
    }
    catch ( IOException e )
    {
    return;
    }
    }
    }
    }
      

  2.   

    /**
     * 
     */
    package test;import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.IOException;/**
     * @author Administrator
     * 
     */
    public class ShanChu { private static void tiao_shi() {
    double ww;
    double qq; BufferedReader obg_reader = new BufferedReader(new InputStreamReader(
    System.in));
    System.out.println("请输入你的数字");
    try {
    ww = new Double(obg_reader.readLine()).doubleValue();
    System.out.println("请再次输入你的数字");
    qq = new Double(obg_reader.readLine()).doubleValue();
    System.out.println(ww + "+" + qq + "=" + (ww + qq));
    } catch (IOException e) {
    } String rr;
    System.out.println("是否继续输入y或Y");
    try {
    rr = (obg_reader.readLine()).toString();
    if (rr.trim().equalsIgnoreCase("y")) {
    tiao_shi();
    }
    } catch (IOException e) {
    }
    } /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub tiao_shi(); }}
      

  3.   

    搂主的程序:
    1、类名首字母要大些(习惯)。
    2、不要使用goto。
      

  4.   

    “==”使用起來要注意,這是全比較,最好用“equals”。