try using two float variables 1. the main float 2. the randomized one and then u will only need to do is 2-1…