Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- "strconv"
- )
- func main() {
- var neededBeers, deliveredBeers int64
- fmt.Scanln(&neededBeers)
- var input1, input2 string
- fmt.Scan(&input1)
- fmt.Scan(&input2)
- for (input1 + " " + input2) != "Exam Over" {
- amount, _ := strconv.ParseInt(input1, 10, 64)
- beerPackage := input2
- if beerPackage == "sixpacks" {
- amount *= 6
- } else if beerPackage == "cases" {
- amount *= 24;
- }
- deliveredBeers += amount
- fmt.Scan(&input1)
- fmt.Scan(&input2)
- }
- deliveredBeers -= deliveredBeers / 100
- diff := int64(math.Abs(float64(neededBeers - deliveredBeers)))
- cases := diff / 24
- sixpacks := diff % 24 / 6
- beers := diff % 6
- if deliveredBeers >= neededBeers {
- fmt.Printf("Cheers! Beer left: %d cases, %d sixpacks and %d beers.", cases, sixpacks, beers);
- } else {
- fmt.Printf("Not enough beer. Beer needed: %d cases, %d sixpacks and %d beers.", cases, sixpacks, beers);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement