22 lines
436 B
Go
22 lines
436 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func f2c(temp_F float32) float32 {
|
|
return 5.0/9.0 * (temp_F-32);
|
|
}
|
|
|
|
func main() {
|
|
var temp_F float32
|
|
fmt.Print("please enter a temperature: ")
|
|
fmt.Scan(&temp_F)
|
|
temp_C := f2c(temp_F)
|
|
|
|
fmt.Printf("%0.4fF as:\n", temp_F)
|
|
fmt.Printf("an int: %dF\n", int(temp_F))
|
|
fmt.Printf("a celsius float32: %0.4fC\n", temp_C)
|
|
fmt.Printf("a celcius int: %dC\n", int(temp_C))
|
|
}
|