Advertisement
Spocoman

Gold Mine

Oct 10th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.67 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var locations, dayDigging int
  6.     fmt.Scanln(&locations)
  7.    
  8.     var averageGold, gold float64
  9.  
  10.     for i := 0; i < locations; i++ {
  11.         fmt.Scanln(&averageGold)
  12.         fmt.Scanln(&dayDigging)
  13.         goldSum := 0.0
  14.         for j := 0; j < dayDigging; j++ {
  15.             fmt.Scanln(&gold)
  16.             goldSum += gold
  17.         }
  18.  
  19.         if goldSum / float64(dayDigging) >= averageGold {
  20.             fmt.Printf("Good job! Average gold per day: %.2f.\n", goldSum / float64(dayDigging))
  21.         } else {
  22.             fmt.Printf("You need %.2f gold.\n", averageGold - (goldSum / float64(dayDigging)))
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement