Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "math"
- "strconv"
- )
- func main() {
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- budget,_ := strconv.ParseFloat(scanner.Text(), 64)
- scanner.Scan()
- volume,_ := strconv.Atoi(scanner.Text())
- var name string
- var price float64
- for i := 0; i < volume; i++ {
- scanner.Scan()
- name = scanner.Text()
- scanner.Scan()
- price,_ = strconv.ParseFloat(scanner.Text(), 64)
- switch name {
- case "Thrones":
- price *= 0.5
- case "Lucifer":
- price *= 0.6
- case "Protector":
- price *= 0.7
- case "TotalDrama":
- price *= 0.8
- case "Area":
- price *= 0.9
- }
- budget -= price
- }
- if budget >= 0 {
- fmt.Printf("You bought all the series and left with %.2f lv.\n", budget)
- } else {
- fmt.Printf("You need %.2f lv. more to buy the series!\n", math.Abs(budget))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement