Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java. How can I fix my code to include a exception handler that deals with nonnumeric operands, ArithmeticException and any others that is required??? 1e
Java. How can I fix my code to include a exception handler that deals with nonnumeric operands, ArithmeticException and any others that is required???
1e isport java.uti1.Scanner a 2 isport java.text.Decinalformat 4 public class Lab 7 ( private static Scanner ingut osus- ne Syste. out-Printin("Hai"-'); Systen.out.pristin("1s Addition") Syste" out-Pristin("2t Sulberertion"); System out . pristin("); matiplication"); System.out prist ?n(.4: Divisio.-); System.out.pristin"S: Exit") int userChoice System.out.printin( Enter a choice:) userchoice estint) uhile (usercholce 1-5) int secondius(int ) 0Math nandon) 10) switch (userchoice) ( Syste out printlefirstNn+secondu int addinginput if (addingiputadeing) nextint ) Systen.out.printle cerrect) Systen out.printie"Y else is wrng The correct anser is "adding) break case 21 ?nt sub-.ir,"Nan - see eedN.na systes out.pristin(firsthe esecond) Systes.out.pristin"cerrect) Systes out,pristinC Yeur swer is wrang. The correct answers+) else breaki case3 int sult firstNssecondn Systes.out.printl"correct) Systee.out.printin"Your answer is rong. The cerrect anseer is malt) else while (second // to sake sure the bottoe nusber 1s never e seconius-(int)Rath,roMath.rnde)1)) double di- firstum/secondu Systes.out printlnfstsc double divInput input.nextDeuble)a Systes.out.printin"corect") else "di) Systes.out.printla(Your answte is wrong The corect ansur s breakj case s System.exit()i break 73 default Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started