Question

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

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("\nWithdraw 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("\nDeposit 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("\nWithdraw 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("\nDeposit 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("\nBalance 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: <>");
   }

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Pseudo code for class BankAccount is here

create a abstract class named as BankAccount
Begins class BankAccount

Declare private variable of double type named balance
Declare private variable of int type named num_deposits
Declare private variable of int type named num_withdraws
Declare private variable of double type named annualInterest
Declare private variable of double type named serviceCharges

parameterised constructor to initialize variable balance and annualInterest

Define a method as public void deposit(double amount) add amount in balance and increment the num_deposits by one

Define a method as public void withdraw(double amount) for withdrow by deductin from balance and increment num_withdraws by one

Define a method as public void calcInterest() to calculate interest as below
monthlyInterestRate = (annualInterest / 12)
monthlyInterest = this.balance * monthlyInterestRate
balance += monthlyInterest;
     
End of method calcInterest

Define a method as public void monthlyProcess() for monthly process as below
  
balance -= serviceCharges
call the method calcInterest
initialize num_deposits by 0
initialize num_withdraws by 0
initialize serviceCharges by 0
     
End of method monthlyProcess

Define methods to get and set the value for the all variables

End of class BankAccount


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

//Pseudo code for concrete class SavingsAccount

Create a concrete class named SavingsAccount by extends BankAccount
Begins class SavingsAccount

//declare a class member which hold status of the account
private variable named status type boolean

contructor begins wiith variable balance and annualInterest
call super constructor with these arguments balance and annualInterest
   //if the initial balance is above 25,
//set the active status to true
start of withdraw
Override withdraw method make it specific as below
check status if true call super class method withdraw and update status
   else display message "Amount cannot be withdrawn"
  
end of    withdraw

start of deposit
Override deposit method with below logic

//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.


end od deposit

start of monthlyProcess
Override method monthlyProcess with logic
//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

end of monthlyProcess

//getter and setter for the status named as getStatus, setStatus

End of class SavingsAccount

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

//Pseudo code for concrete class SavingsAccount

Create a concrete class named BankSavingAccountDemo for demo

begins BankSavingAccountDemo

begins main method
Create an object of the savingsAccount by passing
initial value

Display the initial amount and its value     

Withdraw an amount of 20$ and then print the details
  
   Deposit an amount of 3$ and then print the details
  
   Withdraw an amount of 10$ and then print details
  
   Deposit an amount of $25 and the print the details
  
   Call the monthly process, in order to set the amount with
interest and service charges
  
   Ends main method  
  
   Define a method called printStatus as public static void printStatus(boolean status)
  
   begins printStatus
   printStatus() that accepts a boolean argument and prints the status
of the account depending on the boolean value
     
   ends printStatus
  
Ends class BankSavingAccountDemo
     

Add a comment
Know the answer?
Add Answer to:
please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • If I enter a negative value the program throws an error and the withdrawal amount is...

    If I enter a negative value the program throws an error and the withdrawal amount is added to the balance please help me find why? public abstract class BankAccount { private double balance; private int numOfDeposits; private int numOfwithdrawals; private double apr; private double serviceCharge; //Create getter and setter methods public double getBalance() { return balance; } public void setBalance(double balance) { this.balance = balance; } public int getNumOfDeposits() { return numOfDeposits; } public void setNumOfDeposits(int numOfDeposits) { this.numOfDeposits =...

  • /* * To change this license header, choose License Headers in Project Properties. * To change...

    /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package checkingaccounttest; // Chapter 9 Part II Solution public class CheckingAccountTest { public static void main(String[] args) {    CheckingAccount c1 = new CheckingAccount(879101,3000); c1.deposit(350); c1.deposit(220); c1.withdraw(100); c1.deposit(1100); c1.deposit(700); c1.withdraw(350); c1.withdraw(220); c1.withdraw(100); c1.deposit(1100); c1.deposit(700); c1.deposit(1000); System.out.println(c1); System.out.println("After calling computeMonthlyFee()"); c1.computeMonthlyFee(); System.out.println(c1); } } class BankAccount { private int...

  • pls write psuedocode write UML CODE ALSO example 3 files 1 for abstract 1 for bank...

    pls write psuedocode write UML CODE ALSO example 3 files 1 for abstract 1 for bank account and 1 for savings accounts due in 12 hours Lab Assignment 4a Due: June 13th by 9:00 pm Complete the following Programming Assignment. Use good programming style and all the concepts previously covered. Submit the java files electronically through Canvas by the above due date in 1 Zip file Lab4.Zip. (This is from the chapter on Inheritance.) 9. BankAccount and SavingsAccount Classes Design...

  • BankAccount and SavingsAccount Classes (JAVA)

    Must be in GUI interfaceDesign an abstract class namedBankAccountto hold the following data for a bankaccount:* Balance* Number of deposits this month* Number of withdrawals (this month)* Annual interest rate* Monthly service chargesThe class should have the following methods:Constructor: The constructor should accept arguments for the balance and annual interest rate.deposit: A method that accepts an argument for the amount of the deposit. The methods should add the argument to the account balance. It should also increment thevariable holding the...

  • Use the Java codes below (Checking Account and Checking Account Demo), and work on these problems....

    Use the Java codes below (Checking Account and Checking Account Demo), and work on these problems. You have to do both of your java codes based on the two provided Java codes. Create one method for depositing and one for withdrawing. The deposit method should have one parameter to indicate the amount to be deposited. You must make sure the amount to be deposited is positive. The withdraw method should have one parameter to indicate the amount to be withdrawn...

  • TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static...

    TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...

  • I need to update the code listed below to meet the criteria listed on the bottom....

    I need to update the code listed below to meet the criteria listed on the bottom. I worked on it a little bit but I could still use some help/corrections! import java.util.Scanner; public class BankAccount { private int accountNo; private double balance; private String lastName; private String firstName; public BankAccount(String lname, String fname, int acctNo) { lastName = lname; firstName = fname; accountNo = acctNo; balance = 0.0; } public void deposit(int acctNo, double amount) { // This method is...

  • NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the...

    NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the current displayed customer PLEASEEEEEEEEEE package bankexample; import java.util.UUID; public class Customer { private UUID id; private String email; private String password; private String firstName; private String lastName;    public Customer(String firstName, String lastName, String email, String password) { this.id = UUID.randomUUID(); this.firstName = firstName; this.lastName = lastName; this.email = email; this.password = password; } public String getFirstName() { return firstName; } public void setFirstName(String...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT