Advertisement
Spocoman

05. Cinema Tickets

Sep 24th, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.18 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var seats, standardTickets, studentTickets, kidTickets int  
  7.     var movie, category string
  8.     fmt.Scanln(&movie)
  9.    
  10.     for movie != "Finish" {
  11.         var counter = 0
  12.         fmt.Scanln(&seats)
  13.         for counter != seats {
  14.             fmt.Scanln(&category)
  15.             if category == "End" {
  16.                 break
  17.             } else if category == "standard" {
  18.                 standardTickets++
  19.             } else if category == "student" {
  20.                 studentTickets++
  21.             } else {
  22.                 kidTickets++
  23.             }
  24.             counter++
  25.         }
  26.         fmt.Printf("%s - %.2f%% full.\n", movie, float64(counter) / float64(seats) * 100.0)
  27.         fmt.Scanln(&movie)
  28.     }
  29.    
  30.     var totalTickets = studentTickets + standardTickets + kidTickets
  31.  
  32.     fmt.Printf("Total tickets: %d\n", totalTickets)
  33.     fmt.Printf("%.2f%% student tickets.\n", float64(studentTickets) / float64(totalTickets) * 100.0)
  34.     fmt.Printf("%.2f%% standard tickets.\n", float64(standardTickets) / float64(totalTickets) * 100.0)
  35.     fmt.Printf("%.2f%% kids tickets.\n", float64(kidTickets) / float64(totalTickets) * 100.0)
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement