Checkpoint 1
27 Feb 2023Description
Your goal is to write a Swift playground that:
Creates a constant holding any temperature in Celsius. Converts it to Fahrenheit by multiplying by 9, dividing by 5, then adding 32. Prints the result for the user, showing both the Celsius and Fahrenheit values.
Code
let cTemp = 32
var fTemp = ((cTemp * 9) / 5) + 32
print("C value is \(cTemp)\nF value is \(fTemp)")
Explanation
Here we use let
in order to make the celsius variable a constant.
After this I create the fTemp variable using the var
keyword creating a changeable variable.
Finally I print the two values.