Page 127 - Computer Science V2.0 Class 11
P. 127

next150Rate ← 10
                      above250Rate ← 20
                      meterCharges ← 75


                      if unitsConsumed <= 100 then
                          first100Charge = unitsConsumed * first100Rate
                          next150Charge = 0
                          above250Charge = 0
                      else
                          first100Charge = 100 * first100Rate
                          if unitsConsumed <= 250 then
                              next150Charge = (unitsConsumed - 100) * next150Rate
                              above250charge = 0
                          else
                          next150Charge = 150 * next150Rate
                          above250Charge = (unitsConsumed - 250) * above250Rate


                      totalWaterBill  first100Charge + next150Charge + above250Charge + meter_charges
                   12.  What are conditionals? When they are required in a program?
                  Ans.   In the field of computer science, conditionals are features of a programming language that carry out various computations or actions
                      depending on whether a boolean condition that is specified by the programmer evaluates to true or false. Conditionals are required in a
                      program when we need to calculate a result based on the condition(s) that have been specified.
                   13.  Match the pairs

                                             Flowchart Symbols                    Functions

                                                                                Flow of Control

                                                                                 Process Step


                                                                             Start/Stop of the Process



                                                                                    Data

                                                                                Decision Making

                  Ans.  Refer to 4.2.2 Computing Simple Interest, Flowchart
                   14.  Following is an algorithm for going to school or college. Can you suggest improvements in this to include other options?
                      Reach_School_Algorithm
                      a.  Wake up
                      b.  Get ready
                      c.  Take lunch box
                      d.  Take bus
                      e.  Get off the bus
                      f.  Reach school or college
                  Ans.  a.  Wake up
                      b.  Brush our teeth
                      c.  Do some exercise
                      d.  Take a bath
                      e.  Get ready

                                                                                                     Problem Solving  113
   122   123   124   125   126   127   128   129   130   131   132