Problem Account Class You are a programmer for the Home JMSB Bank. You have been
ID: 3795122 • Letter: P
Question
Problem Account Class You are a programmer for the Home JMSB Bank. You have been assigned to develop a class that models the basic workings of a bank account. The class should have the following properties Balance Holds the current account balance IntRate Interest: Holds the interest earned for the current period. Transactions: Holds the number of transactions for the current period. Holds the interest rate for the period. Write at least three constructors. Include properties for each of the data items. Create a second class that instantiates the first class with information about your account The class should also have the following methods MakeDeposit Takes an argument, which is the amount of the deposit. This argument is added to the Balance property Another method to Display transaction and Display the new balance Sample run JMSB Bank Current Account Details Transaction Number: 3 Current Balance : 1000 .00 Interest Rate: 6.15 Interest Earned: 150.00 Make Deposit Deposit: 100.00 New Balance: 1100.0e Press any key to go to the Account Update CalulatorExplanation / Answer
Hi Friend, You have not mentioned aboutn programming language.
Please try to provide all details.
I have done implementation in JAVA.
@@@@@@@@@ Account.java @@@@@@@@@@@@
public class Account {
// instance variables
private double balance;
private double rate;
private double interest;
private int transaction;
// constructor
public Account(){
balance = 0;
rate = 0;
interest = 0;
transaction = 0;
}
public Account(double balance){
this.balance = balance;
this.rate = 0;
interest = 0;
transaction = 1;
}
public Account(double balance, double rate){
this.balance = balance;
this.rate = rate;
interest = balance*rate/100;
transaction = 1;
}
public Account(double balance, double rate, int tran){
this.balance = balance;
this.rate = rate;
interest = balance*rate/100;;
transaction = tran;
}
public void calcInterest() {
this.interest = rate*balance/100;
}
// getters and setters
public double getBalance() {
return balance;
}
public double getRate() {
return rate;
}
public double getInterest() {
return interest;
}
public int getTransaction() {
return transaction;
}
public void setBalance(double balance) {
this.balance = balance;
}
public void setRate(double rate) {
this.rate = rate;
}
public void setTransaction(int transaction) {
this.transaction = transaction;
}
public void makeDeposite(double amount){
balance = balance + amount;
}
}
@@@@@@@@@@@@@ AcccountTest.java @@@@@@@@@@@@@
import java.util.Scanner;
public class AccountTest {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// creating Account class
Account account = new Account(1000, 15, 3);
System.out.println("Transaction Number: "+account.getTransaction());
System.out.println("Current Balance: "+account.getBalance());
System.out.println("Interest Rate: "+account.getRate());
System.out.println("nterest Earned: "+account.getInterest());
System.out.println("Make Deposite");
System.out.print("Deposite: ");
account.makeDeposite(sc.nextDouble());
System.out.println("New Balance: "+account.getBalance());
System.out.println("Press any key to go to Account Update Calculator");
sc.next();
System.out.println("Account Update Calculator");
System.out.print("Please Enter Current Balance: ");
account.setBalance(sc.nextDouble());
System.out.print("Please Enter Deposite Amount: ");
account.makeDeposite(sc.nextDouble());
System.out.print("Please Enter Transcation Number: ");
account.setTransaction(sc.nextInt());
System.out.print("Please Enter Interest Rate(in %): ");
account.setRate(sc.nextDouble());
System.out.println("Updated Account Details");
System.out.println("New Transaction Number: "+account.getTransaction());
System.out.println("Current Balance: "+account.getBalance());
System.out.println("Interest Rate: "+account.getRate());
System.out.println("nterest Earned: "+account.getInterest());
System.out.println("Updated Deposite Details");
System.out.print("Deposite: ");
account.makeDeposite(sc.nextDouble());
System.out.println("New Balance: "+account.getBalance());
System.out.println("Press any key to exit");
sc.next();
}
}
/*
Sample run:
Transaction Number: 3
Current Balance: 1000.0
Interest Rate: 15.0
nterest Earned: 150.0
Make Deposite
Deposite: 100.0
New Balance: 1100.0
Press any key to go to Account Update Calculator
y
Account Update Calculator
Please Enter Current Balance: 3000
Please Enter Deposite Amount: 250
Please Enter Transcation Number: 11
Please Enter Interest Rate(in %): 2.4
Updated Account Details
New Transaction Number: 11
Current Balance: 3250.0
Interest Rate: 2.4
nterest Earned: 150.0
Updated Deposite Details
Deposite: 250.0
New Balance: 3500.0
Press any key to exit
e
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.