diff --git a/eBook/exercises/chapter_12/calculator.go b/eBook/exercises/chapter_12/calculator.go index 87b32fc..9f2b8fe 100755 --- a/eBook/exercises/chapter_12/calculator.go +++ b/eBook/exercises/chapter_12/calculator.go @@ -31,21 +31,23 @@ func main() { i, _ := strconv.Atoi(token) calc1.Push(i) case token == "+": - q := calc1.Pop() - p := calc1.Pop() - fmt.Printf("The result of %d %s %d = %d\n", p, token, q, p + q) + q, _ := calc1.Pop() + p, _ := calc1.Pop() + fmt.Printf("The result of %d %s %d = %d\n", p, token, q, p.(int) + q.(int)) case token == "-": - q := calc1.Pop() - p := calc1.Pop() - fmt.Printf("The result of %d %s %d = %d\n", p, token, q, p - q) + q, _ := calc1.Pop() + p, _ := calc1.Pop() + fmt.Printf("The result of %d %s %d = %d\n", p, token, q, p.(int) - q.(int)) + case token == "*": - q := calc1.Pop() - p := calc1.Pop() - fmt.Printf("The result of %d %s %d = %d\n", p, token, q, p * q) + q, _ := calc1.Pop() + p, _ := calc1.Pop() + fmt.Printf("The result of %d %s %d = %d\n", p, token, q, p.(int) * q.(int)) + case token == "/": - q := calc1.Pop() - p := calc1.Pop() - fmt.Printf("The result of %d %s %d = %d\n", p, token, q, p / q) + q, _ := calc1.Pop() + p, _ := calc1.Pop() + fmt.Printf("The result of %d %s %d = %d\n", p, token, q, p.(int) / q.(int)) default: fmt.Println("No valid input") }