问题描述
- 运行一直有错误,求大家帮我看看,我实在找不出来问题= =
-
import java.io.*;
public class AccountDemo
{
public static void main(String args[])
{
CheckingAccount a1=new CheckingAccount();
System.out.println("请开账户");
int accNum2,num;
double balance;
String aname,a,b;
try
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入开户人的姓名:");
aname=in.readLine();
System.out.print("请输入开户人的帐号:");
a=in.readLine();
accNum1=Integer.valueOf(a).intValue();System.out.println("======服务======="); System.out.println("1 取钱 2 存钱 3 查询 4结束"); b=in.readLine(); num=Integer.valueOf(b).intValue(); System.out.println("请输入您所需要的操作!"); } catch(Exception e) { System.out.println("您输入的数据有误!"); return; } Account.name=aname; Account.accNum=accNum1; while(num!=4) { if(num==1) { a1.withdraw(); try { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("======服务======="); System.out.println("1 取钱 2 存钱 3 查询 4结束"); b=in.readLine(); num=Integer.valueOf(b).intValue(); } catch(Exception e) { System.out.println("您输入的数据有误!"); return; } } if(num==2) { a1.deposit(); try { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("======服务======="); System.out.println("1 取钱 2 存钱 3 查询 4结束"); b=in.readLine(); num=Integer.valueOf(b).intValue(); } catch(Exception e) { System.out.println("您输入的数据有误!"); return; } } if(num==3) { a1.dispaly(); try { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("======服务======="); System.out.println("1 取钱 2 存钱 3 查询 4结束"); b=in.readLine(); num=Integer.valueOf(b).intValue(); } catch(Exception e) { System.out.println("您输入的数据有误!"); return; } } } }
}
class CheckingAccount extends Account
{
public static double overdraft=0;
public static double limit=500;
public static double withdraw()
{
double q1;
String q;
try
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入取款额:");
q=in.readLine();
q1=Double.valueOf(q).doubleValue();
}
catch(Exception e)
{
System.out.println("您输入的数据有误!");
return balance;
}
if(q1<=balance)
{
balance=balance-q1;
System.out.println("操作成功!");
return balance;
}
else if(q1>balance+limit-overdraft)
{
System.out.println("透支达到上限,拒绝透支!");
return balance;
}
else if(balance
{
balance=0;
overdraft=q1-balance+overdraft;
System.out.println("操作成功!已透支!");
return overdraft;
}
}
public static double deposit()
{
double s;
String d;
try
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入存款额:");
d=in.readLine();
s=Double.valueOf(d).doubleValue();
}
catch(Exception e)
{
System.out.println("您输入的数据有误!");
return balance;
}
if(overdraft=0)
{
balance=s+balance;
System.out.println("操作成功!");
return balance;
}
if(overdraft>=s)
{
overdraft=overdraft-s;
System.out.println("操作成功!");
return overdraft;
}
if(overdraft<s)
{
overdraft=0;
balance=s-overdraft+balance;
return balance;
}
}
}class Account
{
public static String name;
public static int accNum;
public static double balance;public Account(double balance) { this.balance=balance; } public static double withdraw() { double r; String c; try { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.print("请输入取款额:"); c=in.readLine(); r=Double.valueOf(c).doubleValue(); } catch(Exception e) { System.out.println("您输入的数据有误!"); return balance; } if(r<balance) { balance=balance-r; System.out.println("操作成功!"); return balance; } else System.out.println("余额不足!"); return balance; } public static double deposit() { double s; String d; try { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.print("请输入存款额:"); d=in.readLine(); s=Double.valueOf(d).doubleValue(); } catch(Exception e) { System.out.println("您输入的数据有误!"); return balance; } balance=s+balance; System.out.println("操作成功!"); return balance; } public static void dispaly() { System.out.println("姓名:"+name); System.out.println("帐号:"+accNum); System.out.println("余额:"+balance); }
}
解决方案
报什么错?
可以先自己断点 debug 调试下
解决方案二:
自己看看错误提示,如果还解决不了就把报错贴出来看看
解决方案三:
不提供报错信息怎么整?估计是你的Integer转换超整数限了
解决方案四:
吧错误信息粘出来,你可以自己debug一下
解决方案五:
把报错信息粘一下吧,这样看不出问题在哪