33 lines
733 B
Go
33 lines
733 B
Go
|
package main
|
||
|
|
||
|
import "fmt"
|
||
|
import "os"
|
||
|
import "strconv"
|
||
|
|
||
|
var miles float64
|
||
|
|
||
|
const (
|
||
|
MilesToKm float64 = 1.609344
|
||
|
width = 20
|
||
|
titleMiles = "| Miles: "
|
||
|
titleKm = "| Km: "
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
if miles, err := strconv.ParseFloat(os.Args[1], 64); err == nil {
|
||
|
fmtMiles := strconv.FormatFloat(miles, 'f', 2, 64)
|
||
|
fmtKm := strconv.FormatFloat(miles*MilesToKm, 'f', 2, 64)
|
||
|
|
||
|
fmt.Println("<!DOCTYPE html>")
|
||
|
fmt.Println("<html>")
|
||
|
fmt.Println(" <head><title>Miles to Kilometers</title></head>")
|
||
|
fmt.Println(" <body>")
|
||
|
fmt.Println(" <p>Miles:", fmtMiles, "</p>")
|
||
|
fmt.Println(" <p>Kilometers:", fmtKm, "</p>")
|
||
|
fmt.Println(" </body>")
|
||
|
fmt.Println("</html>")
|
||
|
} else {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|