Advertisement
Spocoman

01. Back To The Past

Sep 21st, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.60 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "math"
  6. )
  7.  
  8. func main() {
  9.     var money float64
  10.     fmt.Scanln(&money)
  11.    
  12.     var year int
  13.     fmt.Scanln(&year)
  14.  
  15.     var ivanchoAge = 18
  16.  
  17.     for i := 1800; i <= year; i++ {
  18.         if i % 2 == 0 {
  19.             money -= 12000
  20.         } else {
  21.             money -= float64(12000 + 50 * ivanchoAge)
  22.         }
  23.         ivanchoAge++
  24.     }
  25.  
  26.     if money < 0 {
  27.         fmt.Printf("He will need %.2f dollars to survive.", math.Abs(money))
  28.     } else {
  29.         fmt.Printf("Yes! He will live a carefree life and will have %.2f dollars left.", money)
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement