import java.io.*; class OverPriceException extends Exception { OverPriceException() { System.out.println("Price is greater than 5000 "); } } class Item { String item_name; int item_code; float item_price; Item( String item_name,int item_code,float item_price) { this.item_name=item_name; this.item_code=item_code; this.item_price=item_price; } } public class Main { public static void main(String[] args) throws IOException { String item_name; int item_code; float item_price; try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter Item Name:"); item_name=br.readLine(); System.out.println("Enter Item Code:"); item_code=Integer.parseInt(br.readLine()); System.out.println("Enter Item Price:"); item_price=Float.parseFloat(br.readLine()); if(item_price>5000) throw new OverPriceException(); System.out.println(" Item Name:"+item_name); System.out.println(" Item Code:"+item_code); System.out.println(" Item Price:"+item_price); } catch(OverPriceException e) { } } }
0 Comments
Thanks,To visit this blog.