The Go program below has a syntax error. Can you identify it and fix the code so the program compiles and runs properly?
Custom types and type aliases
Spot and fix the mistake
Report a typo
Sample Input 1:
100Sample Output 1:
665.15Write a program in Go
package main
import "fmt"
type Temperature = float64
// nolint: gomnd // DO NOT remove this comment!
func (t Temperature) CelsiusToFahrenheit() Temperature {
return t*9/5 + 32
}
// nolint: gomnd // DO NOT remove this comment!
func (t Temperature) FahrenheitToKelvin() Temperature {
return t + 273.15
}
func (t Temperature) AddTemperature(other Temperature) Temperature {
return t + other
}
func main() {
var t1 Temperature
fmt.Scan(&t1)
t2 := t1.AddTemperature(t1)
t3 := t2.CelsiusToFahrenheit()
t4 := t3.FahrenheitToKelvin()
fmt.Println(t4)
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.