-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
32 lines (22 loc) · 836 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"flag"
"fmt"
)
func main() {
showerFlowMinute := flag.Float64("shower", 9.5, "Shower water flow in liters per minute.")
flushFlow := flag.Float64("flush", 4, "Water flow in liters in a single flush.")
flag.Parse()
showerFlowSeconds := *showerFlowMinute / 60;
fmt.Print("Enter how long did your pee last (in seconds): ")
var peeTime float64
fmt.Scanln(&peeTime)
waterSpent := peeTime * showerFlowSeconds;
if waterSpent < *flushFlow {
fmt.Printf("You saved %.2f liters of water by peeing in the shower. Good job I guess.\n", *flushFlow - waterSpent)
}
if waterSpent >= *flushFlow {
fmt.Println("You are wasting water!")
fmt.Printf("By peeing in the shower for longer than %.0f seconds, contrary to popular belief, you are actually wasting water.\n", *flushFlow / showerFlowSeconds)
}
}