Advertisement
Spocoman

04. Toy Shop

Sep 16th, 2024
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.89 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var amount float64
  6.     fmt.Scanln(&amount)
  7.    
  8.     var puzzles, dolls, bears, minions, trucks int
  9.     fmt.Scanln(&puzzles)
  10.     fmt.Scanln(&dolls)
  11.     fmt.Scanln(&bears)
  12.     fmt.Scanln(&minions)
  13.     fmt.Scanln(&trucks)
  14.    
  15.     var puzzlePrice = float64(puzzles) * 2.60
  16.     var dollsPrice = float64(dolls) * 3.00
  17.     var bearsPrice = float64(bears) * 4.10
  18.     var minionsPrice = float64(minions) * 8.20
  19.     var trucksPrice = float64(trucks) * 2.00
  20.     var toys = puzzles + dolls + bears + minions + trucks
  21.     var price = puzzlePrice + dollsPrice + bearsPrice + minionsPrice + trucksPrice
  22.  
  23.     if (toys >= 50) {
  24.         price *= 0.75
  25.     }
  26.  
  27.     price *= 0.9
  28.  
  29.     if (price >= amount) {
  30.         fmt.Printf("Yes! %.2f lv left.", price - amount)
  31.     } else {
  32.         fmt.Printf("Not enough money! %.2f lv needed.", amount - price)
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement