Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Which of the following conditions are equivalent (that means have the same tr

ID: 3788866 • Letter: 1

Question

1. Which of the following conditions are equivalent (that means have the same true value)?

a) num != 0 d) !num

b) num == 0 e) !(num == 0)

c) num

2. Suppose that a person’s age is stored in the variable age, his number of children in the variable numChild, his salary in the variable salary, and his height in the variable height. Write the relational expressions to specify the following conditions:

he is 45 year old.

he is more than 5.7 feet tall.

his salary is between 35,000 and 50,000.

he does not have 3 children.

he is either 6.0 feet tall, or he has less than 4 children.

he is not older than 35 and he has 2 or 3 children

Explanation / Answer

Question 1:

Answer:

a) num != 0 and e) !(num == 0)

are equivalent

Question 2:

Answer:

he is 45 year old.

if(age == 45){

}

he is more than 5.7 feet tall.

if (height > 5.7){

}

his salary is between 35,000 and 50,000.

if(salary >= 35000 && salary <= 50000){

}

he does not have 3 children.

if(numChild== 0){

}

he is either 6.0 feet tall, or he has less than 4 children.

if(height == 6.0 || numChild < 4) {

}

he is not older than 35 and he has 2 or 3 children

if(age < 35 && (numChild == 2 || numChild == 3)){

}