Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- var money float64
- fmt.Scanln(&money)
- var year int
- fmt.Scanln(&year)
- var ivanchoAge = 18
- for i := 1800; i <= year; i++ {
- if i % 2 == 0 {
- money -= 12000
- } else {
- money -= float64(12000 + 50 * ivanchoAge)
- }
- ivanchoAge++
- }
- if money < 0 {
- fmt.Printf("He will need %.2f dollars to survive.", math.Abs(money))
- } else {
- fmt.Printf("Yes! He will live a carefree life and will have %.2f dollars left.", money)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement