Answered step by step
Verified Expert Solution
Link Copied!

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???
image text in transcribed
image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions

Question

Assume that 0 Answered: 1 week ago

Answered: 1 week ago