Advertisement
Spocoman

Running In The Park

Oct 12th, 2024
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.65 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var n, dayMinutes, totalMinutes, totalCalories int
  7.     fmt.Scanln(&n)
  8.  
  9.     var dayDistance, totalDistance float64
  10.     var distanceUnit string
  11.  
  12.     for i := 0; i < n; i++ {
  13.         fmt.Scanln(&dayMinutes)
  14.         fmt.Scanln(&dayDistance)
  15.         fmt.Scanln(&distanceUnit)
  16.  
  17.         if distanceUnit == "m" {
  18.             dayDistance *= 0.001
  19.         }
  20.         totalMinutes += dayMinutes
  21.         totalDistance += dayDistance
  22.         totalCalories += dayMinutes * 400 / 20
  23.     }
  24.  
  25.     fmt.Printf("He ran %.2fkm for %d minutes and burned %d calories.", totalDistance, totalMinutes, totalCalories)
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement