java编译后Exception in thread "main" java.lang.Error: Unresolved compilation problem:
importjava.io.*;importjava.util.*;importjava.io.IOException;publicclassbankaccount{pr...
import java.io.*;
import java.util.*;
import java.io.IOException;
public class bankaccount {
private String account_name,id,psw;
private Calendar now;
private float remain_account;
private int account_no,year,month,day;
static int count=0;
public void start_account(String name,String id,float remain,String psw){
//开户
count++;
account_no=count;
account_name=name;
this.id=id;
this.psw=psw;
remain_account=remain;
Calendar now=Calendar.getInstance();
System.out.println("你的账户已开启,账户信息为:");
System.out.println("账户号:"+account_no+" "+"用户名:"+account_name+" "+"开户时间:"+now.get(Calendar.YEAR)+"-"+now.get(Calendar.MONTH)+"-"+now.get(Calendar.DATE)+" "+"存入:"+remain+"元");
}
public void qukuan(float sum) throws IOException{
byte buffer[]=new byte[3];
System.out.println("请输入密码:");
int mycount=System.in.read(buffer);
String input=new String(buffer);
if(this.psw.equals(input)){
if(this.remain_account<=sum){
this.remain_account=this.remain_account-sum;
System.out.println("取款成功,当前余额为:"+this.remain_account);
return;
}
else{
System.out.println("余额不足!");
return;
}
}
else {
System.out.println("密码错误!");
return;
}
}
public int chaxun() throws IOException{
byte buffer[]=new byte[3];
System.out.println("请输入密码:");
int mycount=System.in.read(buffer);
String input=new String(buffer);
if(this.psw.equals(input)){
return this.remain_account;
}
else{
System.out.println("密码错误!");
return 0;
}
}
}
public class TestBank {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
byte buffer[]=new byte[100];
boolean j=true;
bankaccount newacc=new bankaccount();
while(j){
System.out.println();
System.out.println("请选择1或2");
System.out.println("1.开户");
System.out.println("2.取款");
System.out.println("3.退出");
int mycount=System.in.read(buffer);
String input="";
int i=buffer[0]-48;
input=input+i;
switch(new Integer(input)){
case 1:newacc.start_account("姓名", "010101", 5000, "123");break;
case 2:newacc.qukuan(500) ;break;
case 3:j=false;break;
default:System.out.println("输入错误!");
}
}
}
} 展开
import java.util.*;
import java.io.IOException;
public class bankaccount {
private String account_name,id,psw;
private Calendar now;
private float remain_account;
private int account_no,year,month,day;
static int count=0;
public void start_account(String name,String id,float remain,String psw){
//开户
count++;
account_no=count;
account_name=name;
this.id=id;
this.psw=psw;
remain_account=remain;
Calendar now=Calendar.getInstance();
System.out.println("你的账户已开启,账户信息为:");
System.out.println("账户号:"+account_no+" "+"用户名:"+account_name+" "+"开户时间:"+now.get(Calendar.YEAR)+"-"+now.get(Calendar.MONTH)+"-"+now.get(Calendar.DATE)+" "+"存入:"+remain+"元");
}
public void qukuan(float sum) throws IOException{
byte buffer[]=new byte[3];
System.out.println("请输入密码:");
int mycount=System.in.read(buffer);
String input=new String(buffer);
if(this.psw.equals(input)){
if(this.remain_account<=sum){
this.remain_account=this.remain_account-sum;
System.out.println("取款成功,当前余额为:"+this.remain_account);
return;
}
else{
System.out.println("余额不足!");
return;
}
}
else {
System.out.println("密码错误!");
return;
}
}
public int chaxun() throws IOException{
byte buffer[]=new byte[3];
System.out.println("请输入密码:");
int mycount=System.in.read(buffer);
String input=new String(buffer);
if(this.psw.equals(input)){
return this.remain_account;
}
else{
System.out.println("密码错误!");
return 0;
}
}
}
public class TestBank {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
byte buffer[]=new byte[100];
boolean j=true;
bankaccount newacc=new bankaccount();
while(j){
System.out.println();
System.out.println("请选择1或2");
System.out.println("1.开户");
System.out.println("2.取款");
System.out.println("3.退出");
int mycount=System.in.read(buffer);
String input="";
int i=buffer[0]-48;
input=input+i;
switch(new Integer(input)){
case 1:newacc.start_account("姓名", "010101", 5000, "123");break;
case 2:newacc.qukuan(500) ;break;
case 3:j=false;break;
default:System.out.println("输入错误!");
}
}
}
} 展开
2个回答
展开全部
你的程序在
chaxun的method里面有问题
你的method返回类型为int
但你return的是float
改为:public float chaxun() throws IOException{
chaxun的method里面有问题
你的method返回类型为int
但你return的是float
改为:public float chaxun() throws IOException{
追问
已经改过了,但是依旧出现Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at TestBank.main(bankaccount.java:66)
追答
你看下报的at TestBank.main(bankaccount.java:66)
是在哪一行代码~
你贴出来的代码 看不了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询