Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
635 B

  1. package main
  2. import "fmt"
  3. func main() {
  4. // Main course
  5. var total float64 = 2 * 13
  6. fmt.Println("Sub:", total)
  7. // Drinks
  8. total = total + (4 * 2.25)
  9. fmt.Println("Sub:", total)
  10. // Discount
  11. total = total - 5
  12. fmt.Println("Sub:", total)
  13. // 10% Tip
  14. tip := total * 0.1
  15. fmt.Println("Tip:", tip)
  16. total = total + tip
  17. fmt.Println("Total:", total)
  18. // Split bill
  19. split := total / 2
  20. fmt.Println("Split:", split)
  21. // Reward every 5th visit
  22. visitCount := 24
  23. visitCount = visitCount + 1
  24. remainder := visitCount % 5
  25. if remainder == 0 {
  26. fmt.Println("With this visit, you've earned a reward.")
  27. }
  28. }