Question

In: Computer Science

Consider the following variable declarations hours = 40; status= True; overtime = False What is the...

  1. Consider the following variable declarations

hours = 40;

status= True;

overtime = False

What is the value of each of the following Boolean expressions?       [4 marks]

  1. status and !status
  2. status or  !status
  3. overtime == (hours >= 40)
  4. False == hours > 40

Solutions

Expert Solution

i. Given status = True, !status is opposite of status, hence !status = False

    we need to find status and !status. and expressions returns true only if both the expressions are true. Otherwise and returns false . Hence

status and !status = True and False = False

ii. As shown in the above section, status = True and !status = False.

    We need to find status or !status. or returns true if either of the expressions it evaluates is true. or return false only if both expressions it evaluates is false. Hence,

status or !status = True or False = True

iii. Given overtime = False and hours = 40.

     The expression hours>=40 return True because hours=40

       The expression overtime == (hours>=40) checks whether the variable overcome and the output of hours>=40 are the same.

But overtime = False and hours>=40= True. Hence the expression returns False because LHS and RHS are not the same.

iv. Here LHS = False.

     RHS = hours>40 . Since hours = 40, this return False. Hence RHS = False

    ==> LHS = RHS which is what the == expression checks. Hence the expression returns True.


Related Solutions

An employee works 48 hours (48 - 40 were overtime hours) during a workweek in December...
An employee works 48 hours (48 - 40 were overtime hours) during a workweek in December of 2019. He earns $8,000/month, with his employer paying 1.5 times the regular rate of pay for overtime hours. To date, he has earned $110,300 during the year. He has requested that his employer withhold 11.5% of gross pay to contribute to a 403(b) plan. Taxable income for federal income tax withholding = $ Taxable income for social security tax = $ Taxable income...
Leticia Alvarez worked 40 hours straight time and 20 hours overtime at an hourly rate of...
Leticia Alvarez worked 40 hours straight time and 20 hours overtime at an hourly rate of $10.50. Of the 20 hours overtime, 8 hours were at double time. Compute the following: 30. Straight-time earnings = 31. Overtime earnings = 32. Gross earnings =
PATENT LAW: True or False. A patent pending status does not give an inventor the status...
PATENT LAW: True or False. A patent pending status does not give an inventor the status to sue a copycat for infringement. Explain.
What would be the amount of Regular Hours and Overtime based on Alberta and Federal for...
What would be the amount of Regular Hours and Overtime based on Alberta and Federal for the following 4 weeks. No averaging system is in place. May M T W T F S Su 8 8 8 8 8 4 9 7 8 9 10   10 10 10 10    8 8 8 8 8 8
True, False or Uncertain: Improvements in the health status of the population of a developing country...
True, False or Uncertain: Improvements in the health status of the population of a developing country will typically result in higher average income. Explain your answer.
True or False: The life in hours of a battery is known to be approximately normally...
True or False: The life in hours of a battery is known to be approximately normally distributed, with standard deviation of 15 hours. A random sample of 16 batteries has a mean life of 110 hours. Based on sampling results, there is sufficient evidence on this sample to support the claim that battery life exceeds 100 hours at α=0.05.
True/False/Uncertain. Support your Answer ⦁ Income, a socioeconomic determinant of health status, affects health status because...
True/False/Uncertain. Support your Answer ⦁ Income, a socioeconomic determinant of health status, affects health status because it reduces ability to purchase health care but health status can also reduce ability to earn income by reducing productive time.
True/False: Indicate whether the following statement is true or false. If it is false, indicate the...
True/False: Indicate whether the following statement is true or false. If it is false, indicate the reason. If it is true, indicate what makes it true. Just stating true or false will not earn any points. "It is not possible to have concave preferences."
Given the following variable declarations: const size_t n = 50; Write the declaration of an array...
Given the following variable declarations: const size_t n = 50; Write the declaration of an array of pointers to n memory blocks containing 16-bit signed integer values. Use 'x' for the name of the variable. (Don't forget the semi-colon at the end of the declaration!)
Consider the following definitions given to you for Boolean logic: not = λx.((x false) true) true...
Consider the following definitions given to you for Boolean logic: not = λx.((x false) true) true = λx.λy.x false = λx.λy.y Show that not (not true) evaluates to true. Your steps must use proper substitutions and each step must be accompanied with a brief explanation (e.g., "replacing the bound x with false", etc.). You can use "L" for the lambda symbol in your answer.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT