package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
fmt.Printf("Type the year you were born: ")
scanner.Scan()
input, _ := strconv.ParseInt(scanner.Text(), 10, 64)
fmt.Printf("You will be %d years old at the end of 2020", 2020-input)
}
//cmd
C:\Users\bob\golang1>go run tutorial.go
Type the year you were born: 2000
You will be 20 years old at the end of 2020
reference:
No comments:
Post a Comment