Advertisement
Spocoman

02. Bike Race

Sep 19th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.87 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var juniorCount, seniorCount int
  6.     fmt.Scanln(&juniorCount)
  7.     fmt.Scanln(&seniorCount)
  8.    
  9.     var trace string
  10.     fmt.Scanln(&trace)
  11.  
  12.     var juniorPrice = 0.0
  13.     var seniorPrice = 0.0
  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.     var 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