Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- var name string
- fmt.Scanln(&name)
- var budget float64
- fmt.Scanln(&budget)
- var beers, chips int
- fmt.Scanln(&beers)
- fmt.Scanln(&chips)
- beerPrice := float64(beers) * 1.20
- chipsPrice := float64(chips) * beerPrice * 0.45
- sum := beerPrice + math.Ceil(chipsPrice)
- if budget < sum {
- fmt.Printf("%s needs %.2f more leva!\n", name, sum - budget)
- } else {
- fmt.Printf("%s bought a snack and has %.2f leva left.\n", name, budget - sum)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement