From the course: Learning Go

Unlock this course with a free trial

Join today to access over 24,200 courses taught by industry experts.

Solution: Create a more advanced calculator app

Solution: Create a more advanced calculator app - Go Tutorial

From the course: Learning Go

Solution: Create a more advanced calculator app

(upbeat music) - [Instructor] In a previous code challenge, you created a simple application that just knew how to add two values together. In this more complex challenge, you're asked to support multiple mathematical operations and to do that by structuring your code with multiple functions. The default values that are passed in are values of 10 and 5.5, and just as in the previous challenge, they start as strings and have to be converted to floats. And then you set the operation with a single character, plus, minus, times, and divide. I'll test my code with these default values and show that I get back a value of 15.5 and then I'll change the operation. This time I'll use the asterisk for multiplication and I'll test again and I get back the correct answer. Here's how I structured my code. First, I implemented the function convertInputToValue. Now, within this editor, you can do a little trick here. I can hold down…

Contents