Advertisement
Spocoman

01. Dishwasher

Sep 22nd, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.90 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "strconv"
  6. )
  7.  
  8. func main() {
  9.     var detergentCount, charging int
  10.     fmt.Scanln(&detergentCount)
  11.  
  12.     var detergentMl = detergentCount * 750
  13.     var counter = 0
  14.     var dishes = 0
  15.     var pots = 0
  16.  
  17.     var input string
  18.     fmt.Scanln(&input)
  19.  
  20.     for detergentMl >= 0 && input != "End" {
  21.         charging,_ = strconv.Atoi(input)
  22.         counter++
  23.         if counter % 3 != 0 {
  24.             dishes += charging
  25.             detergentMl -= charging * 5
  26.         } else {
  27.             pots += charging
  28.             detergentMl -= charging * 15
  29.         }
  30.         fmt.Scanln(&input)
  31.     }
  32.  
  33.     if input == "End" {
  34.         fmt.Printf("Detergent was enough!\n%d dishes and %d pots were washed.\nLeftover detergent %d ml.\n", dishes, pots, detergentMl)
  35.     } else {
  36.         fmt.Printf("Not enough detergent, %d ml. more necessary!", detergentMl * -1)
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement