Advertisement
Spocoman

Fitness Card

Oct 9th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.16 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var cash float64
  7.     fmt.Scanln(&cash)
  8.    
  9.     var gender string
  10.     fmt.Scanln(&gender)
  11.    
  12.     var age int
  13.     fmt.Scanln(&age)
  14.    
  15.     var sport string
  16.     fmt.Scanln(&sport)
  17.    
  18.     sum := 0.0
  19.    
  20.     if gender == "m" {
  21.         switch sport {
  22.         case "Gym":
  23.             sum = 42
  24.         case "Boxing":
  25.             sum = 41
  26.         case "Yoga":
  27.             sum = 45
  28.         case "Zumba":
  29.             sum = 34
  30.         case "Dances":
  31.             sum = 51
  32.         case "Pilates":
  33.             sum = 39
  34.         }
  35.     } else {
  36.         switch sport {
  37.         case "Gym":
  38.             sum = 35
  39.         case "Boxing":
  40.             sum = 37
  41.         case "Yoga":
  42.             sum = 42
  43.         case "Zumba":
  44.             sum = 31
  45.         case "Dances":
  46.             sum = 53
  47.         case "Pilates":
  48.             sum = 37
  49.         }
  50.     }
  51.        
  52.     if age <= 19 {
  53.         sum *= 0.8
  54.     }
  55.  
  56.     if sum <= cash {
  57.         fmt.Printf("You purchased a 1 month pass for %s.", sport)
  58.     } else {
  59.         fmt.Printf("You don't have enough money! You need $%.2f more.\n", sum - cash)
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement