Page 112 - Learn To Program With Scratch
P. 112

3.  Write a procedure that converts degrees Celsius to degrees Fahrenheit
                             as shown below. Have the script round the answer to the nearest inte-
                             ger. Test your procedure for different temperatures. (Hint: °F = (9 / 5)
                             × °C + 32.)









                         4.  Write a procedure to create the house shown
                             on the right. Start by writing small proce-
                             dures that draw small parts of the house (for
                               example, door, roof, windows, and so on).
                             Then combine these procedures to  create
                             the entire house.
                         5.  Write a procedure to compute the area of
                                          2
                             a circle (A = πr ) given its radius, as shown
                             below. Use π = 3.14.








            PressureUnder   6.  In this exercise, you’ll simulate the pressure experienced by fish under
                 Water_      water. Assume that the pressure P (in atmospheres) felt by a fish is
           NoSolution .sb2   related to its depth d (in meters from the surface) by the relation:
                             P = 0.1d + 1. PressureUnderWater_NoSolution.sb2 contains a partial imple-
                             mentation of this simulation. Finish the script so that the fish says the
                             pressure it feels while swimming, as illustrated below:

                              0 meters
                                          Depth





                              50 meters








                             100 meters




           90   Chapter 4
                                           www.it-ebooks.info
   107   108   109   110   111   112   113   114   115   116   117