From d4647fd0ae66b531c6e4866b322b77b9d52cdca4 Mon Sep 17 00:00:00 2001 From: raul Date: Sun, 21 Jan 2024 16:16:07 +0100 Subject: [PATCH] Added temp-conversion exercise --- temp-conversion/go.mod | 3 +++ temp-conversion/main.go | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 temp-conversion/go.mod create mode 100644 temp-conversion/main.go diff --git a/temp-conversion/go.mod b/temp-conversion/go.mod new file mode 100644 index 0000000..76fcbc9 --- /dev/null +++ b/temp-conversion/go.mod @@ -0,0 +1,3 @@ +module temp-conversion + +go 1.21.6 diff --git a/temp-conversion/main.go b/temp-conversion/main.go new file mode 100644 index 0000000..664a5da --- /dev/null +++ b/temp-conversion/main.go @@ -0,0 +1,19 @@ +package main + +import "fmt" + +var cel float64 +var fah float64 + +func main() { + fmt.Println("Celsius to Fahrenheit converter") + fmt.Println("Write a temperature in celsius") + fmt.Scan(&cel) + celsiusToFahrenheit(cel) + fmt.Printf("%v degrees Celsius are equivallent to %v degrees Fahrenheit\n", cel, fah) +} + +func celsiusToFahrenheit(cel float64) { + fah = cel*1.8 + 32 + return +}