Added temp-conversion exercise

This commit is contained in:
raul 2024-01-21 16:16:07 +01:00
parent e56ec312f6
commit d4647fd0ae
2 changed files with 22 additions and 0 deletions

3
temp-conversion/go.mod Normal file
View File

@ -0,0 +1,3 @@
module temp-conversion
go 1.21.6

19
temp-conversion/main.go Normal file
View File

@ -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
}