1 Star 0 Fork 0

CS-IMIS-23 / 20172306

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
NewAccount.java 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
20172306 提交于 2018-04-04 17:06 . PP7.1
//
// this is about PP7.1.
//
import java.text.NumberFormat;
public class NewAccount
{
private final double RATE=0.035;
private long acctNumber;
private double balance;
private String name;
//
// Sets up the account by defining its owner,account number,
// and initial balance.
//
public NewAccount(String owner,long account)
{
name = owner;
acctNumber = account;
}
//
// Deposits the specified 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);
}
}
Java
1
https://gitee.com/CS-IMIS-23/20172306.git
git@gitee.com:CS-IMIS-23/20172306.git
CS-IMIS-23
20172306
20172306
master

搜索帮助