開発環境
- macOS Mojave - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Visual Studio Code (Text Editor)
- Go (プログラミング言語)
Head First Go (Jay McGavren(著)、O'Reilly Media)のChapter 1(let's get going - Syntax Basics)、Exercise(24)の解答を求めてみる。
コード
package main import ( "fmt" ) func main() { price := 100 fmt.Println("Price is", price, "dollars.") taxRate := 0.08 tax := float64(price) * taxRate fmt.Println("Tax is", tax, "dollras.") total := float64(price) + tax fmt.Println("Total cost is", total, "dollars.") availableFunds := 120 fmt.Println(availableFunds, "dollars available.") fmt.Println("Within badget?", total <= float64(availableFunds)) }
入出力結果(Bash、cmd(コマンドプロンプト)、Terminal)
$ go run sample3.go Price is 100 dollars. Tax is 8 ollras. Total cost is 108 dollars. 120 dollars available. Within badget? true $ go run sample3.go
0 コメント:
コメントを投稿