源代码1:
package banking;
public class Account {
private double balance;
public Account(double init_balance){
balance = init_balance;
}
public double getBalance(){
return balance;
}
public void deposit(double amt){
balance +=amt;
}
public void withdraw(double amt){
balance -=amt;
}
}
源代码2:
package test;
import banking.*;
public class TestBanking {
public static void main(String[] args){
Account account;
account = new Account(500);
account.deposit(22.50);
account.withdraw(47.50);
}
}
运行后,console控制台有反应,无结果?求助ing
运行一切ok,但就是不出结果?(我用的eclipse,我的return返回值也不显示)
答案:1 悬赏:50 手机版
解决时间 2021-01-31 09:16
- 提问者网友:情歌越听越心酸
- 2021-01-30 23:01
最佳答案
- 五星知识达人网友:纵马山川剑自提
- 2021-01-30 23:38
没有输出,给你改下
class Account {
private double balance;
public Account(double init_balance) {
balance = init_balance;
}
public double getBalance() {
return balance;
}
public void deposit(double amt) {
balance += amt;
}
public void withdraw(double amt) {
balance -= amt;
}
public String toString() {
return balance + "";
}
}
class TestBanking {
public static void main(String[] args) {
Account account;
account = new Account(500);
account.deposit(22.50);
account.withdraw(47.50);
System.out.println(account);
}
}
class Account {
private double balance;
public Account(double init_balance) {
balance = init_balance;
}
public double getBalance() {
return balance;
}
public void deposit(double amt) {
balance += amt;
}
public void withdraw(double amt) {
balance -= amt;
}
public String toString() {
return balance + "";
}
}
class TestBanking {
public static void main(String[] args) {
Account account;
account = new Account(500);
account.deposit(22.50);
account.withdraw(47.50);
System.out.println(account);
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯