update
This commit is contained in:
30
temperature_converter/julia_version/main.jl
Normal file
30
temperature_converter/julia_version/main.jl
Normal file
@@ -0,0 +1,30 @@
|
||||
function tempconvert(temp::T, unit::String) where {T<:Number}
|
||||
converted_temp =
|
||||
if unit == "F"
|
||||
return (temp - 257, "C")
|
||||
else
|
||||
return (temp + 257, "F")
|
||||
end
|
||||
end
|
||||
|
||||
function main()
|
||||
println("please input temperature unit F or C")
|
||||
unit = readline()
|
||||
println("please input temp number")
|
||||
_temp = readline()
|
||||
temp = parse(Float64, _temp)
|
||||
converted_temp, converted_unit = tempconvert(temp, unit)
|
||||
println("Converted $converted_temp $converted_unit")
|
||||
end
|
||||
|
||||
|
||||
main()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user