Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "strconv"
- )
- func main() {
- var detergentCount, charging int
- fmt.Scanln(&detergentCount)
- var detergentMl = detergentCount * 750
- var counter = 0
- var dishes = 0
- var pots = 0
- var input string
- fmt.Scanln(&input)
- for detergentMl >= 0 && input != "End" {
- charging,_ = strconv.Atoi(input)
- counter++
- if counter % 3 != 0 {
- dishes += charging
- detergentMl -= charging * 5
- } else {
- pots += charging
- detergentMl -= charging * 15
- }
- fmt.Scanln(&input)
- }
- if input == "End" {
- fmt.Printf("Detergent was enough!\n%d dishes and %d pots were washed.\nLeftover detergent %d ml.\n", dishes, pots, detergentMl)
- } else {
- fmt.Printf("Not enough detergent, %d ml. more necessary!", detergentMl * -1)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement