import java.util.*; class B extends RuntimeException { B(String a) { super(a); } public static void main(String... args) { int balance=1700; Scanner x=new Scanner(System.in); System.out.print("Enter amount="); int amount=x.nextInt(); if(amount>balance) { throw new B("Invalid balance"); } else { System.out.println("Your Amount ="+amount); } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter