Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "strconv"
- )
- func main() {
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- movies,_ := strconv.Atoi(scanner.Text())
- var movie, maxMovie, minMovie string
- var rating, maxRating, totalRating float64
- minRating := 10.0
- for i := 0; i < movies; i++ {
- scanner.Scan()
- movie = scanner.Text()
- scanner.Scan()
- rating,_ = strconv.ParseFloat(scanner.Text(), 64)
- if rating > maxRating {
- maxMovie = movie
- maxRating = rating
- }
- if rating < minRating {
- minMovie = movie
- minRating = rating
- }
- totalRating += rating
- }
- fmt.Printf("%s is with highest rating: %.1f\n", maxMovie, maxRating)
- fmt.Printf("%s is with lowest rating: %.1f\n", minMovie, minRating)
- fmt.Printf("Average rating: %.1f\n", totalRating / float64(movies))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement