BlueJ中无法检测到错误

时间:2015-01-01 08:42:06

标签: java

import java.io.*;
public class Test
{
    private final String Name;
    private final int AccNo;
    private String AccTyp;
    private double Bal;
    private double BalNew;
    private int c=0;
    private final int x=0;
    private int t;
    InputStreamReader isr = new InputStreamReader (System.in);
    BufferedReader br = new BufferedReader (isr);
    Test()throws IOException
    {
        System.out.println("Enter Name:");
        Name = br.readLine();
        System.out.println("Enter Account Number:");
        AccNo = Integer.parseInt(br.readLine());
        t = AccNo;
        {
            while(t>0)
            {
                c++;
                t = t/10;
            }
        }
        if(c!=10)
        {
            System.out.println("Invalid Account Number!");
            System.exit(0);
        }   
        else
        {
                System.out.println("Enter Account Type (Recurring, Savings, Current, Fixed):");
                AccTyp = br.readLine();
                if(AccTyp.equals("Recurring") || AccTyp.equals("Savings") || AccTyp.equals("Current") || AccTyp.equals("Fixed"))
                {
                    System.out.println("Enter Balance:");
                    Bal = Double.parseDouble(br.readLine());
                }
            else
            {
                System.out.println("Invalid Account Type!");
                System.exit(0);
            }
        }
    }
    public void display()
    {
        System.out.println("Depositor's Name: " +Name);
        System.out.println("Account No.: " +AccNo);
        System.out.println("Account Type: " +AccTyp);
        System.out.println("Balance: " +Bal);
    }
    public void calculation()throws IOException
    {
        System.out.println("Enter amount to withdraw:");
        double n = Double.parseDouble(br.readLine());
        if(n>Bal)
        {
            System.out.println("Not Enough Balance!");
            System.exit(0);
        }
        else
        {
            BalNew = Bal-n;
        }
    }
    public void New()
    {
        System.out.println("New Balance is: " +BalNew);
        System.out.println("Thank you for your Transaction!");
        System.out.println("Please Visit Again!");
    }
    public static void main(String args[])throws IOException
    {`enter code here`
        Test obj = new Test();
        obj.display();
        obj.calculation();
        obj.New();
    }
}

我的BlueJ上有一些错误。

3 个答案:

答案 0 :(得分:0)

我在eclipse中运行你的代码并且运行正常。 这是输出

输入姓名: XYZ 输入帐号: 1234567891 输入帐户类型(重复,储蓄,当前,固定): 定期 输入余额: 30000 存款人姓名:xyz 帐号:1234567891 帐户类型:重复 余额:30000.0 输入提款金额: 10000 New Balance是:20000.0 谢谢你的交易! 请再次访问!

答案 1 :(得分:0)

我在BlueJ中运行了你的代码,错误在于,在main函数中,行enter code here是一条无用的行。因此,如果我们删除该行程序运行绝对正常:)。

答案 2 :(得分:-1)

我在Net Beans中运行了我的代码并且它提供了很多错误。 1 GT;在上面的程序中,您输入了:

private final int AccNo;
然后你说:

AccNo = Integer.parseInt(br.readLine());

声明变量“final”后,您无法在声明变量后对其进行初始化。所以不要宣布它是决赛。

这是我唯一得到的东西。如果有任何其他错误,将通知您