add chapter 4
This commit is contained in:
23
chapter4/passfail/pass_fail.go
Normal file
23
chapter4/passfail/pass_fail.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"golang-book/head-first-go/chapter4/keyboard"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Print("Enter a grade: ")
|
||||
grade, err := keyboard.GetFloat()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var status string
|
||||
if grade >= 60 {
|
||||
status = "passing"
|
||||
} else {
|
||||
status = "failing"
|
||||
}
|
||||
fmt.Println("A grade of", grade, "is", status)
|
||||
}
|
||||
Reference in New Issue
Block a user