From the course: Java 8+ Essential Training: Syntax and Structure

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 8+ Essential Training: Syntax and Structure

Start my 1-month free trial

Challenge: A more complex calculator

- [Instructor] Here's another challenge you can use to test your knowledge of Java. In a previous challenge, you might have created a simple calculator that received two values and added the values together. In this version of the calculator, it can handle more than just addition. This calculator once again asks for two numeric values. I will type in 34 and 12.5, but then it prompts for an operation. The user has to enter plus, minus, asterisk, or slash, and then the application will execute the code based on the operation that they ask for. So if I type in an asterisk, I get a multiplication operation. I'll run the code again, and I'll enter the same two values as before, and this time, I'll ask for addition, and I get a different answer. As you build this version of the calculator, think about creating custom methods. One custom method for receiving input, and four different custom methods, one for each mathematical operation. To evaluate the operation that's entered, try using a…

Contents