[小女在国外学习]有一道Java编程的英文作业题,远程求助国内大神们,明天要交。。。求大神们救急!!
CreateaclasscalledBankAccountwiththesefields:idNumber,nameandbalance.Providereadersan...
Create a class called BankAccount with these fields: idNumber, name and balance. Provide readers and writers for all these fields. Each writer should return the previous value of the field it updates. Provide all appropriate constructors plus methods conformingto these method headers:
1.1 public void deposit( BigDecimal amount ) // add amount to current balance
1.2 public boolean withdraw( BigDecimal amount ) // subtract amount from current balance; return false if not enough money
(We mentioned the BigDecimal class when we discussed the shortcomings of the float and double primitive types -- look it up in the Javadoc documentation available through the Eclipse IDE menu system, or directly from Oracle.)
2. Create a sub-class of BankAccount called SavingsAccount, adding this field: interestRate. Also add a method conforming to this header:
public BigDecimal calcInterest() // add (balance*interestRate) to balance
(This is a very naive way to handle interest calculations)
3. Write a test driver class called "Driver" to exercise all the methods of the BankAccount and SavingsAccount classes, clearly printing inputs and outputs, so the grader can easily tell what works (everything, we hope) and what doesn't.
救急救急救急。。。求程序
原题 图片 不知道看得清不
在线等~~~~~~
继续等等等~~~
提高悬赏 等等等~~~~· 展开
1.1 public void deposit( BigDecimal amount ) // add amount to current balance
1.2 public boolean withdraw( BigDecimal amount ) // subtract amount from current balance; return false if not enough money
(We mentioned the BigDecimal class when we discussed the shortcomings of the float and double primitive types -- look it up in the Javadoc documentation available through the Eclipse IDE menu system, or directly from Oracle.)
2. Create a sub-class of BankAccount called SavingsAccount, adding this field: interestRate. Also add a method conforming to this header:
public BigDecimal calcInterest() // add (balance*interestRate) to balance
(This is a very naive way to handle interest calculations)
3. Write a test driver class called "Driver" to exercise all the methods of the BankAccount and SavingsAccount classes, clearly printing inputs and outputs, so the grader can easily tell what works (everything, we hope) and what doesn't.
救急救急救急。。。求程序
原题 图片 不知道看得清不
在线等~~~~~~
继续等等等~~~
提高悬赏 等等等~~~~· 展开
1个回答
展开全部
What's ur email, i will send the full version to you.
package testProject;
import java.math.BigDecimal;
public class BankAccount {
protected String idNumber;
protected String name;
protected BigDecimal balance;
//default constructor
public BankAccount(){
idNumber = "";
name = "";
balance = BigDecimal.ZERO;
}
//Create a default balance account
public BankAccount(String idNumber, String name){
this.idNumber = idNumber;
this.name = name;
this.balance = BigDecimal.ZERO;
}
//Create a account with deposit
public BankAccount(String idNumber, String name, BigDecimal balance){
this.idNumber = idNumber;
this.name = name;
this.balance = balance;
}
//make deposit
public void deposit(BigDecimal amount){
balance = balance.add(amount);
}
//withdraw money
public boolean withdraw(BigDecimal amount){
if(balance.compareTo(amount)<0){
return false;
}else{
balance = balance.subtract(amount);
return true;
}
}
//Reader of IdNumber
public String getIdNumber() {
return idNumber;
}
//Writer of IdNumber
public String setIdNumber(String idNumber) {
String oldIdNumber = this.idNumber;
this.idNumber = idNumber;
return oldIdNumber;
}
//Reader of Name
public String getName() {
return name;
}
//Writer of Name
public String setName(String name) {
String oldName = this.name;
this.name = name;
return oldName;
}
//Reader of balance
public BigDecimal getBalance() {
return balance;
}
//Writer of balance
public BigDecimal setBalance(BigDecimal balance) {
BigDecimal oldBalance = new BigDecimal(this.balance.doubleValue());
this.balance = balance;
return oldBalance;
}
}
追问
my email is
lbh9127atgmail.com
at =@
你看能上传到哪里 我能下载下来么
追答
I was in the middle of something. Will send to you shortly after wrapping it up. Will take 15min more.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询