Advertisement
Spocoman

Bike Race

Oct 3rd, 2024
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.85 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var juniorCount, seniorCount int
  7.     fmt.Scanln(&juniorCount)
  8.     fmt.Scanln(&seniorCount)
  9.    
  10.     var trace string
  11.     fmt.Scanln(&trace)
  12.  
  13.     var juniorPrice, seniorPrice float64
  14.  
  15.     switch trace {
  16.         case "trail":
  17.             juniorPrice = 5.50
  18.             seniorPrice = 7.00
  19.         case "cross-country":
  20.             juniorPrice = 8.00
  21.             seniorPrice = 9.50
  22.         case "downhill":
  23.             juniorPrice = 12.25
  24.             seniorPrice = 13.75
  25.         case "road":
  26.             juniorPrice = 20.00
  27.             seniorPrice = 21.50
  28.     }
  29.  
  30.     sum := juniorPrice * float64(juniorCount) + seniorPrice * float64(seniorCount)
  31.  
  32.     if trace == "cross-country" && juniorCount + seniorCount >= 50 {
  33.         sum *= 0.75
  34.     }
  35.    
  36.     fmt.Printf("%.2f\n", sum * 0.95)
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement