Advertisement
Spocoman

Cinema

Oct 4th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.72 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "strconv"
  6. )
  7.  
  8. func main() {
  9.     var seats, groupCount, income int  
  10.     fmt.Scanln(&seats)
  11.  
  12.     var command string
  13.     fmt.Scanln(&command)
  14.    
  15.     for command != "Movie time!" {
  16.         groupCount, _ = strconv.Atoi(command)
  17.         if groupCount > seats {
  18.             break
  19.         }
  20.  
  21.         seats -= groupCount
  22.         income += groupCount * 5
  23.  
  24.         if groupCount % 3 == 0 {
  25.             income -= 5
  26.         }
  27.         fmt.Scanln(&command)
  28.     }
  29.  
  30.     if command == "Movie time!" {
  31.         fmt.Printf("There are %d seats left in the cinema.\n", seats)
  32.     } else {
  33.         fmt.Println("The cinema is full.")
  34.     }
  35.     fmt.Printf("Cinema income - %d lv.\n", income)
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement