Advertisement
Spocoman

Workout

Oct 14th, 2024
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.66 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "math"
  6. )
  7.  
  8. func main() {
  9.     var days int
  10.     fmt.Scanln(&days)
  11.    
  12.     var kilometers, percentage float64
  13.     fmt.Scanln(&kilometers)
  14.    
  15.     totalKilometers := kilometers
  16.    
  17.     for i := 0; i < days; i++ {
  18.         fmt.Scanln(&percentage)
  19.         kilometers *= (100 + percentage) / 100
  20.         totalKilometers += kilometers
  21.     }
  22.  
  23.     if totalKilometers < 1000 {
  24.         fmt.Printf("Sorry Mrs.Ivanova, you need to run %d more kilometers", 1000 - int(totalKilometers))
  25.     } else {
  26.         fmt.Printf("You've done a great job running %d more kilometers!", int(math.Ceil(totalKilometers) - 1000))
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement