1 Star 1 Fork 0

CS-IMIS-23/20172313yukunpeng

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Account.java 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
余坤澎 提交于 7年前 . docs:practice
//**********************************************************
// Account.java Author
//
//**********************************************************
import java.text.NumberFormat;
public class Account
{
private final double RATE = 0.035;
private long acctNumber;
private double balance;
private String name;
//-----------------------------------------------------------
// Sets up the account by defining its owner, aacount number,
// and inital balance
//-----------------------------------------------------------
public Account(String owner, long account, double initial)
{
name = owner;
acctNumber = account;
balance = initial;
}
//--------------------------------------------------------------
// Deposits thespeciafied amount into the account. Returns the
// new balance
//--------------------------------------------------------------
public double deposit(double amount)
{
balance = balance + amount;
return balance;
}
//--------------------------------------------------------------
// Withdraws the specified amount from the account and applies
// the fee. Returns the new balance
//--------------------------------------------------------------
public double withdraw(double amount, double fee)
{
balance = balance - amount - fee;
return balance;
}
//---------------------------------------------------------------
// Adds interest to the account and returns the new balance
//---------------------------------------------------------------
public double addInterest()
{
balance += (balance * RATE);
return balance;
}
//---------------------------------------------------------------
// Returns the current balance of the account
//---------------------------------------------------------------
public double getBalance()
{
return balance;
}
//----------------------------------------------------------------
// Returns a one-line description of the account as a string;
//----------------------------------------------------------------
public String toString()
{
NumberFormat fmt = NumberFormat.getCurrencyInstance();
return acctNumber + "\t" + name + "\t" + fmt.format(balance);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/CS-IMIS-23/20172313yukunpeng.git
git@gitee.com:CS-IMIS-23/20172313yukunpeng.git
CS-IMIS-23
20172313yukunpeng
20172313yukunpeng
master

搜索帮助