開発環境
- macOS High Sierra - Apple (OS)
- Emacs (Text Editor)
- Go (プログラミング言語)
Introducing Go: Build Reliable, Scalable Programs (Caleb Doxsey (著)、O'Reilly Media)のChapter 3.(Variables)、Exercises(No. 480)5、6.を取り組んでみる。
コード(Emacs)
package main import "fmt" func main() { fmt.Print("Enter a fahrenheit: ") var fahrenheit float64 fmt.Scanf("%f", &fahrenheit) celsius := (fahrenheit - 32) * 5 / 9 fmt.Println(celsius) fmt.Print("Enter a feet: ") var feet float64 fmt.Scanf("%f", &feet) meters := 0.3048 * feet fmt.Println(meters) }
入出力結果(Terminal)
$ go run sample3.go Enter a fahrenheit: 100 37.77777777777778 Enter a feet: 100 30.48 $ go run sample3.go Enter a fahrenheit: 10 -12.222222222222221 Enter a feet: 10 3.048 $
0 コメント:
コメントを投稿