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.
Solution: A more complex calculator - Java Tutorial
From the course: Java 11+ Essential Training
Solution: A more complex calculator
(upbeat music) - [Instructor] In the previous video I challenged you to create a more complex calculator application that would handle exceptions when the user typed in a value that couldn't be parsed as a number. I also said that there should be multiple operations supported, so if the user did type in valid values, they could choose from addition, subtraction, multiplication, or division. Here's my solution to the challenge. First I declared my double values. I used a bit of syntax I haven't covered so far. I declared them both in the same line using a comma to separate them. If you prefer, you could do it like this. Either one works. Next, within the try-catch block I asked the user to enter some values. I collected those values by calling the next double method of the scanner object. I also called next line each time because next double doesn't consume the line feed at the end of the user's data entry.…