Complete the code below according to the instructions below and the example test: method withdraw throws an exception if amount is greater than balance.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter11: Exception Handling
Section: Chapter Questions
Problem 5E
icon
Related questions
Question

Complete the code below according to the instructions below and the example test:


method withdraw throws an exception if amount is greater than balance.

For example:

Test Result

Account account = new Account("Acct-001","Juan dela Cruz", 5000.0); account.withdraw(5500.0);

System.out.println("Balance: "+account.getBalance());

Insufficient: Insufficient funds.

Balance: 5000.0

Account account = new Account("Acct-001","Juan dela Cruz", 5000.0); account.withdraw(500.0);

System.out.println("Balance: "+account.getBalance());

Balance: 4500.0

Incomplete java code:
 
public class Account{
    private String accntNumber;
    private String accntName;
    private double balance;
    
    public Account(){}
    public Account(String num, String name, double bal){
        accntNumber = num;
        accntName = name;
        balance = bal;
    }
    
    public double getBalance(){ return balance;}
}
//your class here
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Exception Handling Keywords
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning