Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank you so much! public abstract class BankAccount { //declare

please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank you so much!

public abstract class BankAccount { //declare the required class variables private double balance; private int num_deposits; private int num_withdraws; private double annualInterest; private double serviceCharges; //constructor that takes two arguments // one is to initialize the balance and other // to initialize the annual interest rate public BankAccount(double balance, double annualInterest) { this.balance = balance; this.annualInterest = annualInterest; this.num_deposits = 0; this.num_withdraws = 0; this.serviceCharges = 0; } //deposit() that accepts an argument to deposit //The amount. Adds the amount to the available //balance and increments num_deposits value public void deposit (double amount) { balance+= amount; num_deposits++; } //Withdraws() that accepts an argument to withdraws //the amount. deducts the amount form the available balance // and increments num_withdraws value public void withdraw(double amount) { balance -= amount; num_withdraws++; } //calcinterest() that calculates the monthly interest from the balance // amount and adds the interest to the balance public void calcInterest() { double monthlyInterestRate = (annualInterest / 12); double monthlyInterest = this.balance * monthlyInterestRate; balance += monthlyInterest; } //monthlyProcess() detects the monthly service charges from the //balance and updates the balance by calling calcinterest() and sets the //num_deposit, num_withdraws, monthly service charge variables to zero public void monthlyProcess() { balance -= serviceCharges; calcInterest(); num_deposits = 0; num_withdraws = 0; serviceCharges = 0; } // getter and setter method for balance public double getBalance() { return balance; } public void setBallance(double balance) { this.balance = balance; } //getter and setter method for num_deposit public int getNum_deposits() { return num_deposits; } public void setNum_deposits(int num_deposits) { this.num_deposits = num_deposits; } //getter and setter method for num_withdraws public int getNum_withdraws() { return num_withdraws; } public void setNum_withdraws(int num_withdraws) { this.num_withdraws = num_withdraws; } //getter and setter for annualInterest public double getAnnualInterest() { return annualInterest; } public void setAnnualInterest(double annualInterest) { this.annualInterest = annualInterest; } //getter and setter method for serviceCharges public double getServiceCharges() { return serviceCharges; } public void setServiceCharges(double serviceCharges) { this.serviceCharges = serviceCharges; }

}

======================================================================================

public class SavingsAccount extends BankAccount { //declare a class member which hold status of the account private boolean status; //constructor public SavingsAccount(double balance, double annualInterest) { //initialize the super class constructor super(balance, annualInterest); //if the initial balance is above 25, //set the active status to true if (balance >= 25) { status = true; } else { status = false; } } //withdraw() this method checks for whether the account is active //or inactive, if the account is active, call the superclass //withdraw method, else, do nothing public void withdraw(double amount) { if(status) { super.withdraw(amount); if(super.getBalance()<25) status = false; } else { System.out.println("Amount cannot be withdrawn"); } } //deposit() this method checks for whether the account is active //or inactive. if the account is inactive, check whether the //amount to be added makes the status to active or not. if it is, //then add the amount and set the status to active. public void deposit(double amount) { if(!status) { double avail = super.getBalance()+ amount; if(avail>= 25) { status = true; } } super.deposit(amount); } //monthlyProcess() first it checks for the number of withdraws //are greater than 4 or not, if the number of deposits are more //than 4 then set the service charges to 1$ for each withdraw for //which withdraws are above 4. at the same time check for balance. //if it is falling less than $25 the set the status to inactive public void monthlyProcess() { int countWithdraws = super.getNum_withdraws(); if(countWithdraws > 4) { super.setServiceCharges(countWithdraws - 4); super.monthlyProcess(); if(super.getBalance() < 25) status = false; } } //getter and setter for the status public boolean isStatus() { return status; } public void setStatus(boolean status) { this.status = status; } }

========================================================================

public class BankSavingAccountDemo {

//main method public static void main (String args[]) { //Create an object of the savingsAccount by passing //initial value SavingsAccount sa = new SavingsAccount(40, 1.5); //Display the initial amount and its value System.out.println("initial account balance is $"+ sa.getBalance()); printStatus(sa.isStatus()); //Withdraw an amount of 20$ and then print the details System.out.println(" Withdraw an amount of $20"); sa.withdraw(20.00); System.out.println("Balance after withdraw: "+ sa.getBalance()); printStatus(sa.isStatus()); //Deposit an amount of 3$ and then print the details System.out.println(" Deposit an amount of 3$"); sa.deposit(3.00); System.out.println("Balance after deposit: "+ sa.getBalance()); printStatus(sa.isStatus()); //Withdraw an amount of 10$ and then print details System.out.println(" Withdraw an amount of $10"); sa.withdraw(10.00); System.out.println("Balance after withdraw is: "+ sa.getBalance()); printStatus(sa.isStatus()); //Deposit an amount of $25 and the print the details System.out.println(" Deposit an amount of $25"); sa.deposit(25.00); System.out.println("Balance after deposit: "+ sa.getBalance()); printStatus(sa.isStatus()); //Call the monthly process, in order to set the amount with //interest and service charges sa.monthlyProcess(); System.out.println(" Balance at the end of the month: "); System.out.println("Balance in the account: "+ sa.getBalance()); printStatus(sa.isStatus()); System.out.println("Number of deposits made: " + sa.getNum_withdraws()); System.out.println("Monthly charges: "+ sa.getServiceCharges()); } //printStatus() that accepts a boolean argument and prints the status //of the account depending on the boolean value public static void printStatus(boolean status) { if(status) System.out.println("Status of the account is: <>"); else System.out.println("Status of the account is: <>"); }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

1. How are language and thought related?

Answered: 1 week ago

Question

LO5 Describe job analysis and the stages in the process.

Answered: 1 week ago