Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var age int
- fmt.Scanln(&age)
- var machinePrice, toyPrice float64
- fmt.Scanln(&machinePrice)
- fmt.Scanln(&toyPrice)
- var sum = 0.0
- var toy = 0.0
- var birthday = 10.0
- for i := 3; i < age + 3; i++ {
- if i % 2 == 0 {
- sum += birthday - 1
- birthday += 10
- } else {
- toy++
- }
- }
- sum += toy * toyPrice
- if sum >= machinePrice {
- fmt.Printf("Yes! %.2f\n", sum - machinePrice)
- } else {
- fmt.Printf("No! %.2f\n", machinePrice - sum)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement