Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Exception Handling

ajf
ajf 


Take any program that you have written and incorporate “exception handling” in your program. My program is attached. I need to add an exception to it. Attachments Tags
Clarifications

Answers

Exception Handler Solution

mariobeka
mariobeka 



Below you'll find your code, with the addition of an exception handler for the input. Attachments
ComputeChange.java (1 K) Download Preview
args) { Scanner input = new Scanner(System.in); double changeDue, amountDue, amount, amountPaid, dollarsDue; int pennies; try { System.out.println("Enter amount Due(in pennies): \t"); amountDue = input.nextDouble(); System.out.println("Enter amount Paid($1, $5, $10 etc):

Screenshots
Purchase Answer

Exception Handling

sudheer488
sudheer488 



Find your code in attachment with added exception Attachments
ComputeChange.java (1 K) Download Preview
* 100); int onedollar= (pennies / 100); pennies=(pennies % 100); int quarter= (pennies / 25); pennies=(pennies % 25); System.out.println ("change due: " +changeDue); System.out.println ("Dollars: " + onedollar); System.out.println

ComputeChange.java (1 K) Download Preview
{ } //parametrized constructor ComputeChange(String str) { super(str); } public static void main (String[] args) { Scanner input = new Scanner(System.in); double changeDue,amountDue, amount, amountPaid, dollarsDue; try{ System.out.println("Enter amount Due(in pennies): \t"); amountDue =

output.PNG (7 K) Download Preview

Screenshots
Screenshot
Purchase Answer