Page 182 - ComputerScience_Class_11
P. 182

D.  Higher Order Thinking Skills (HOTS)

                  1.  Explain how you can use the ternary (conditional) operator as a replacement for an if-else statement. Consider the following
                    scenario: A program needs to decide whether a user is eligible for a discount based on their age (above 18 for eligibility). Write
                    a  program  using  the  ternary  operator  to  check  this  condition  and  print  "Eligible"  or  "Not  Eligible"  accordingly.  Discuss  the
                    advantages and limitations of using the ternary operator in this case.
                  2.  In  Java,  operators  have  different  precedence  and  associativity,  affecting  the  order  of  evaluation  in  an  expression.  Given  an
                    expression such as int result = 10 + 20 * 5 / 2 - 3 % 4;, explain how the precedence of operators influences the final result. How
                    would you modify the expression to change the order of operations and why is it important to understand operator precedence
                    when designing complex expressions?

              E.  Case study-based questions.

                  A digital security system is developed using Java to control access to different sections of a building. Each access permission is
                  represented using bits, where 1 indicates permission granted and 0 indicates permission denied.
                  The program uses bitwise AND to check whether a user has the required permissions for a specific section.

                  Bitwise OR is used to grant additional access rights without removing existing permissions.
                  Bitwise XOR is applied to toggle certain access permissions temporarily.
                  Bitwise NOT is used to revoke all permissions during emergency lockdown situations.
                  The system performs all operations at the bit level using integer data types.
                  Operator precedence ensures that bitwise operations are evaluated correctly before assignment.
                  Based on the given case, answer the following questions:
                  1.  Identify the form used to represent access permissions in the digital security system.
                    a.  Characters                                  b.  Strings
                    c.  Bits                                        d.  Decimal values
                  2.  Which bitwise operator checks whether a user has the required permission?
                    a.  Bitwise OR                                  b.  Bitwise AND
                    c.  Bitwise XOR                                 d.  Bitwise NOT
                  3.  Select the bitwise operator used to grant extra access without removing existing permissions.
                    a.  ~                                           b.  ^
                    c.  |                                           d.  &
                  4.  Mark the operator used to revoke all permissions during an emergency lockdown.
                    a.  Bitwise XOR                                 b.  Bitwise AND
                    c.  Bitwise NOT                                 d.  Bitwise OR

              F.  Write the java program for the following:
                  1.  Write a program to calculate the total price a customer must pay for an item with a discount, based on the following conditions:
                     • If the item price is less than ₹500, apply a 5% discount.
                     • If the item price is between ₹500 and ₹1000, apply a 10% discount.
                     • If the item price is more than ₹1000, apply a 15% discount.
                     Enter the original price of the item: 800

                     Original Price: 800.0
                     Discount: 80.0
                     Final Price: 720.0







                  180  Touchpad Computer Science (Ver. 3.0)-XI
   177   178   179   180   181   182   183   184   185   186   187