Advertisement
Spocoman

04. Fishing Boat

Sep 18th, 2024
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.81 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var budget float64
  6.     fmt.Scanln(&budget)
  7.    
  8.     var season string
  9.     fmt.Scanln(&season)
  10.    
  11.     var people int
  12.     fmt.Scanln(&people)
  13.    
  14.     var sum = 0.0
  15.    
  16.     switch (season) {
  17.         case "Spring":
  18.             sum = 3000
  19.         case "Summer", "Autumn":
  20.             sum = 4200
  21.         case "Winter":
  22.             sum = 2600
  23.     }
  24.  
  25.     if (people <= 6) {
  26.         sum *= 0.90
  27.     } else if (people <= 11) {
  28.         sum *= 0.85
  29.     } else {
  30.         sum *= 0.75
  31.     }
  32.  
  33.     if (people % 2 == 0 && season != "Autumn") {
  34.         sum *= 0.95
  35.     }
  36.  
  37.     if (sum <= budget) {
  38.         fmt.Printf("Yes! You have %.2f leva left.", budget - sum)
  39.     } else {
  40.         fmt.Printf("Not enough money! You need %.2f leva.", sum - budget)
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement