Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- "strconv"
- )
- func main() {
- var kidTickets, studentTickets, standardTickets int
- scanner := bufio.NewScanner(os.Stdin)
- for {
- scanner.Scan()
- movie := scanner.Text()
- if movie == "Finish" {
- break
- }
- scanner.Scan()
- seats,_ := strconv.Atoi(scanner.Text())
- counter := 0
- for i := 0; i < seats; i++ {
- scanner.Scan()
- category := scanner.Text()
- if category == "student" {
- studentTickets++
- } else if category == "standard" {
- standardTickets++
- } else if category == "kid" {
- kidTickets++
- } else {
- break
- }
- counter++
- }
- fmt.Printf("%s - %.2f%% full.\n", movie, float64(counter) / float64(seats) * 100)
- }
- sumTickets := standardTickets + studentTickets + kidTickets
- fmt.Printf("Total tickets: %d\n", sumTickets)
- fmt.Printf("%.2f%% student tickets.\n", float64(studentTickets) / float64(sumTickets) * 100)
- fmt.Printf("%.2f%% standard tickets.\n", float64(standardTickets) / float64(sumTickets) * 100)
- fmt.Printf("%.2f%% kids tickets.\n", float64(kidTickets) / float64(sumTickets) * 100)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement