Subject: Object Oriented Prgramming
Language: Java Program
Topic: Exception
Method withdraw throws an exception if amount is greater than balance.
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
Extracted text: method withdraw throws an exception if amount is greater than balance. For example: Result - new Account ("Acct-001", "Juan dela Cruz", 5000.0); Insufficient: Insufficient funds. 5500.0); Balance: 5000.0 n ("Balance: "+account. getBalance ()); - new Account ("Acct-001", "Juan dela Cruz", 5000.0); Balance: 4500.0 500.0); .n ("Balance: "+account.getBalance () );
Extracted text: 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); Insufficient: In: account.withdraw (5500.0); Balance: 5000.0 System.out.println ("Balance: "+account.getBalance () ); Account account = new Account ("Acct-001", "Juan dela Cruz", 5000.0); Balance: 4500.0 account.withdraw (500.0) ; System.out.println ("Balance: "+account.getBalance () );