Advertisement
Spocoman

Series

Oct 13th, 2024
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.06 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "bufio"
  5.     "fmt"
  6.     "os"
  7.     "math"
  8.     "strconv"
  9. )
  10.  
  11. func main() {
  12.     scanner := bufio.NewScanner(os.Stdin)
  13.     scanner.Scan()
  14.     budget,_ := strconv.ParseFloat(scanner.Text(), 64)
  15.    
  16.     scanner.Scan()
  17.     volume,_ := strconv.Atoi(scanner.Text())
  18.  
  19.     var name string
  20.     var price float64
  21.  
  22.     for i := 0; i < volume; i++ {
  23.         scanner.Scan()
  24.         name = scanner.Text()
  25.        
  26.         scanner.Scan()
  27.         price,_ = strconv.ParseFloat(scanner.Text(), 64)
  28.        
  29.         switch name {
  30.         case "Thrones":
  31.             price *= 0.5
  32.         case "Lucifer":
  33.             price *= 0.6
  34.         case "Protector":
  35.             price *= 0.7
  36.         case "TotalDrama":
  37.             price *= 0.8
  38.         case "Area":
  39.             price *= 0.9
  40.         }
  41.        
  42.         budget -= price
  43.     }
  44.  
  45.     if budget >= 0 {
  46.         fmt.Printf("You bought all the series and left with %.2f lv.\n", budget)
  47.     } else {
  48.         fmt.Printf("You need %.2f lv. more to buy the series!\n", math.Abs(budget))
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement