please code in java..refer the 2 codes BankAccount and AccountTest.. BankAccount source code is given below and AccountTest source code is added in image  Question is  to add code to be able to lock the account. for example if someone withdraws a certain amount of money the accounts locks, etc   /**    The BankAccount class simulates a bank account. */ public class BankAccount {    private double balance;      // Account balance    /**       This constructor sets the starting balance       at 0.0.    */    public BankAccount()    {       balance = 0.0;    }        /**       This constructor sets the starting balance       to the value passed as an argument.       @param startBalance The starting balance.    */    public BankAccount(double startBalance)    {       balance = startBalance;    }    /**       This constructor sets the starting balance       to the value in the String argument.       @param str The starting balance, as a String.    */    public BankAccount(String str)    {       balance = Double.parseDouble(str);    }    /**       The deposit method makes a deposit into       the account.       @param amount The amount to add to the                     balance field.    */    public void deposit(double amount)    {       balance += amount;    }    /**       The deposit method makes a deposit into       the account.       @param str The amount to add to the                  balance field, as a String.    */    public void deposit(String str)    {       balance += Double.parseDouble(str);    }    /**       The withdraw method withdraws an amount       from the account.       @param amount The amount to subtract from                     the balance field.    */    public void withdraw(double amount)    {       balance -= amount;    }    /**       The withdraw method withdraws an amount       from the account.       @param str The amount to subtract from                  the balance field, as a String.    */    public void withdraw(String str)    {       balance -= Double.parseDouble(str);    }    /**       The setBalance method sets the account balance.       @param b The value to store in the balance field.    */    public void setBalance(double b)    {       balance = b;    }    /**       The setBalance method sets the account balance.       @param str The value, as a String, to store in                  the balance field.    */    public void setBalance(String str)    {       balance = Double.parseDouble(str);    }        /**       The getBalance method returns the       account balance.       @return The value in the balance field.    */    public double getBalance()    {       return balance;    } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please code in java..refer the 2 codes BankAccount and AccountTest.. BankAccount source code is given below and AccountTest source code is added in image 

Question is  to add code to be able to lock the account. for example if someone withdraws a certain amount of money the accounts locks, etc

 

/**
   The BankAccount class simulates a bank account.
*/

public class BankAccount
{
   private double balance;      // Account balance

   /**
      This constructor sets the starting balance
      at 0.0.
   */

   public BankAccount()
   {
      balance = 0.0;
   }
   
   /**
      This constructor sets the starting balance
      to the value passed as an argument.
      @param startBalance The starting balance.
   */

   public BankAccount(double startBalance)
   {
      balance = startBalance;
   }

   /**
      This constructor sets the starting balance
      to the value in the String argument.
      @param str The starting balance, as a String.
   */

   public BankAccount(String str)
   {
      balance = Double.parseDouble(str);
   }

   /**
      The deposit method makes a deposit into
      the account.
      @param amount The amount to add to the
                    balance field.
   */

   public void deposit(double amount)
   {
      balance += amount;
   }

   /**
      The deposit method makes a deposit into
      the account.
      @param str The amount to add to the
                 balance field, as a String.
   */

   public void deposit(String str)
   {
      balance += Double.parseDouble(str);
   }

   /**
      The withdraw method withdraws an amount
      from the account.
      @param amount The amount to subtract from
                    the balance field.
   */

   public void withdraw(double amount)
   {
      balance -= amount;
   }

   /**
      The withdraw method withdraws an amount
      from the account.
      @param str The amount to subtract from
                 the balance field, as a String.
   */

   public void withdraw(String str)
   {
      balance -= Double.parseDouble(str);
   }

   /**
      The setBalance method sets the account balance.
      @param b The value to store in the balance field.
   */

   public void setBalance(double b)
   {
      balance = b;
   }

   /**
      The setBalance method sets the account balance.
      @param str The value, as a String, to store in
                 the balance field.
   */

   public void setBalance(String str)
   {
      balance = Double.parseDouble(str);
   }
   
   /**
      The getBalance method returns the
      account balance.
      @return The value in the balance field.
   */

   public double getBalance()
   {
      return balance;
   }
}

import javax.swing. JOptionPane; // For the JOptionPane class
/**
This program demonstrates the BankAccount class.
*/
public class Account Test
{
}
public static void main(String[] args)
{
String input; // To hold user input
// Get the starting balance.
input = JOptionPane.showInput Dialog(
}
"what is your account's starting balance?");
// Create a BankAccount object.
BankAccount account = new BankAccount (input);
// Get the amount of pay.
input =
JOptionPane.showInputDialog(
"How much were you paid this month? ");
// Deposit the user's pay into the account.
account.deposit(input);
// Display the new balance.
JOptionPane.showMessageDialog(null,
String.format("Your pay has been deposited.\n" +
"Your current balance is $%,. 2f",
account.getBalance()));
// withdraw some cash from the account.
input = JOptionPane.showInputDialog(
"How much would you like to withdraw? ");
account. withdraw(input);
// Display the new balance
JOptionPane.showMessageDialog(null,
String.format("Now your balance is $%,.2f",
account.getBalance()));
System.exit(0);
Transcribed Image Text:import javax.swing. JOptionPane; // For the JOptionPane class /** This program demonstrates the BankAccount class. */ public class Account Test { } public static void main(String[] args) { String input; // To hold user input // Get the starting balance. input = JOptionPane.showInput Dialog( } "what is your account's starting balance?"); // Create a BankAccount object. BankAccount account = new BankAccount (input); // Get the amount of pay. input = JOptionPane.showInputDialog( "How much were you paid this month? "); // Deposit the user's pay into the account. account.deposit(input); // Display the new balance. JOptionPane.showMessageDialog(null, String.format("Your pay has been deposited.\n" + "Your current balance is $%,. 2f", account.getBalance())); // withdraw some cash from the account. input = JOptionPane.showInputDialog( "How much would you like to withdraw? "); account. withdraw(input); // Display the new balance JOptionPane.showMessageDialog(null, String.format("Now your balance is $%,.2f", account.getBalance())); System.exit(0);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY