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 - Java Tutorial
From the course: Java 8+ Essential Training: Syntax and Structure
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Evaluate conditions with if-else4m 17s
-
Evaluate conditions with switch-case4m 32s
-
(Locked)
Create looping code blocks7m 13s
-
(Locked)
Create reusable code with methods8m 17s
-
(Locked)
Create overloaded methods3m 27s
-
(Locked)
Pass arguments by reference vs. value4m
-
(Locked)
Challenge: A more complex calculator1m 18s
-
(Locked)
Solution: A more complex calculator2m 20s
-
(Locked)
-