I need help solving the question below. Ive completed some part of it
Declare a variable heartRate of type Int? and set it to nil. Print the value.
var heartRate : Int? = nil
In this example, if the user fixes the positioning of the heart rate monitor, the app may get a proper heart rate reading. Below, update the value of heartRate to 74. Print the value.
heartRate = 74
As you've done in other app exercises, create a variable hrAverage of type Int and use the values stored below and the value of heartRate to calculate an average heart rate.
var hrAverage: Int!
let oldHR1 = 80
let oldHR2 = 76
let oldHR3 = 79
let oldHR4 = 70
hrAverage = (oldHR1 + oldHR2 + oldHR3 + oldHR4 + heartRate!)/5
If you didn't unwrap the value of heartRate, you've probably noticed that you cannot perform mathematical operations on an optional value. You will first need to unwrap heartRate.
Safely unwrap the value of heartRate using optional binding. If it has a value, calculate the average heart rate using that value and the older heart rates stored above. If it doesn't have a value, calculate the average heart rate using only the older heart rates. In each case, print the value of hrAverage.