The exercise for this week is to write a class that simulates managing a simple
ID: 3533422 • Letter: T
Question
The exercise for this week is to write a class that simulates managing a simple bank account. The account is created with an initial balance zero. It is possible to deposit and withdraw funds, to add interest, and to find out the current balance. This should be implemented in class named Account that includes:
A default constructor that sets the initial balance to zero.
A function getBalance that returns the current balance.
A method deposit for depositing a specified amount.
A method withdraw for withdrawing a specified amount.
A method addInterest for adding interest to the account.
The addInterest method takes the interest rate as a parameter and changes the balance in the account to balance*(1+rate).
The UML diagram for the Account class is shown in the following UML diagram.
SHAPE * MERGEFORMAT
The Account Class
Submission: Submit your Account.java class
Remember kids, street racing is dangerous and illegal, and puppies get kicked every time someone sails down University Drive at 80 mph. Think of the puppies, don't street race.
CSE 110 - Lab 10 PAGE * MERGEFORMAT 3 / NUMPAGES * MERGEFORMAT 4
- balance: double
+Account()
+double getBalance()
+void deposit(double amount)
+void withdraw(double amount)
+void addInterest(double rate)
Account
Explanation / Answer
I have successfully executed without any errors
class account
{
double bal,amount,rate;
amount()
{
bal=0;
}
double getbalance() // get balance
{
return bal;
}
void deposite(double amount)// amount to be deposite
{
bal=bal+amount;
}
void withdraw(double amount) // amount to be withdraw
{
bal=bal-amount;
}
void addinterest(double rate)// add interest
{
bal=bal*(1+rate);
}
};//close class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.