Question: Write a java program that implements bank transactions using user defined exception.
import java.util.*;
class UDE{
public
static void main(String ts7[]) throws MinimumBal {
Scanner
sc= new Scanner(System.in);
double
bal;
System.out.println("Enter current
balance:");
bal=sc.nextDouble();
System.out.println("Enter amount to
withdrawal");
int n =
sc.nextInt();
try {
if
(bal<n)
throw new MinimumBal("Account ae taka nei bhai !\nYour Current
balance is "+bal);
else
System.out.println("Money left:"+(bal-n)); }
catch
(MinimumBalmab) {
mab.printStackTrace();
} }
}
class MinimumBal extends Exception{
String
message;
public
MinimumBal(String message) {
this.message = message; }
public
String toString(){
return
message;
}
}
OUTPUT:![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaime9vhohzFdjAhMbUDtSXeAppAu2BA6n9KGRJw-82wQ7Th9csUunEbQguxumCTF7Usoorv0kIuxQ9flPT8W4wrcxQqowdk1jnheKnJ1djKF0__srEEKe59_org0WxrJ017-OkqkbaWJb/s640/1.jpg)
Keywords:
How to recover the classnotfoundexception in Java?
What are the top most requirements or expectations of client for develop Java web application?
Java program question paper in 2020
Comments
Post a Comment