From the course: Java 11+ Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: A more complex calculator

Challenge: A more complex calculator - Java Tutorial

From the course: Java 11+ Essential Training

Start my 1-month free trial

Challenge: A more complex calculator

(upbeat music) - [Instructor] In a previous challenge I built a simple calculator that let the user add a couple of values together. It didn't have any exception handling, and so if you entered a value that couldn't be parsed as a number, the application would crash. Also, it only supported one operation, addition. In this challenge I'll ask you to build a more robust calculator. One that handles exceptions if the user doesn't enter a correct value, and then can execute multiple operations. I'm hiding the code for the finished version, and I'll show you how it behaves. I can enter two values. And then I'm asked to select one of four operations. I'll choose a forward slash for division, and I get back a value of 3.0. If I run the application again, and I enter a value that can't be parsed as a number, I simply get the message, couldn't format as a number. Now, to handle this exception you'll need to find out what…

Contents