Nested conditionals

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

This program uses a nested conditional to assign the variable mystery to a value: IF (x > y) { mystery ← x - y } ELSE { IF (x = y) { mystery ← y / x } ELSE { mystery ← x * y } } If we set x to 4 and y to 8, what value will the mystery variable store after running this code? Choose 1 answer:

32

This program uses a nested conditional to assign the variable mystery to a value: IF (x > y) { mystery ← x - y } ELSE { IF (x < y) { mystery ← y / x } ELSE { mystery ← x + y } } If we set x to 32 and y to 8, what value will the mystery variable store after running this code?

24

This program uses a nested conditional to assign the variable mystery to a value: IF (x > y) { mystery ← x - y } ELSE { IF (x < y) { mystery ← y / x } ELSE { mystery ← x + y } } If we set x to 8 and y to 24, what value will the mystery variable store after running this code?

3

A software engineer for a movie theater is writing a program to calculate ticket prices based on customer ages. The program needs to implement this pricing chart: Ticket typePriceGeneral Admission$16Senior (Ages 65+)$12Child (Ages 2-12)$8Infants (Ages 0-1)Free The code segment below uses nested conditionals to assign the price variable to the appropriate value, but its conditions are missing operators. price ← 0 IF (age <?> 64) { price ← 12 } ELSE { IF (age <?> 12) { price ← 16 } ELSE { IF (age <?> 1) { price ← 8 } } } Which operator could replace <?> so that the code snippet works as expected?

>

A pool manager is writing a program to make sure their swimming pools contain a safe level of chlorine. IF (chlorinePPM > 3.0) { chlorineLevel ← "high" } ELSE { IF (chlorinePPM < 1.0) { chlorineLevel ← "low" } ELSE { chlorineLevel ← "safe" } } Which of these tables shows the expected values of chlorineLevel for the given values of chlorinePPM? Choose 1 answer:

chlorinePPM chlorineLevel 0.0 "low" 0.9 "low" 1.0 "safe" 2.6 "safe" 3.0 "safe" 3.2 "high" 4.5 "high"

Mira is writing a program to help her decide what cheese to pair with what fruit.IF (fruit = "watermelon") { cheese ← "feta" } ELSE { IF (fruit = "peach") { cheese ← "burrata" } ELSE { IF (fruit = "pear") { cheese ← "brie" } ELSE { IF (fruit = "strawberry") { cheese ← "ricotta" } ELSE { cheese ← "goat" } } } }Which of these tables shows expected values for cheese after running this program with a variety of values for fruit?

fruitcheese "mango""goat" "watermelon""feta" "peach""burrata" "fig""goat" "pear""brie" "raspberry""goat" "strawberry""ricotta"

A gardener is writing a program to detect whether the soils for their citrus trees are the optimal level of acidity. IF (measuredPH > 6.5) { soilState ← "high" } ELSE { IF (measuredPH < 5.5) { soilState ← "low" } ELSE { soilState ← "optimal" } } Which of these tables shows the expected values of soilState for the given values of measuredPH?

measuredPH soilState 4.7 "low" 5.4 "low" 5.5 "optimal" 6.2 "optimal" 6.5 "optimal" 6.7 "high" 7.2 "high"

A chemistry student is writing a program to help classify the results of experiments. solutionType ← "unknown" IF (phLevel = 7) { solutionType ← "neutral" } ELSE { IF (phLevel > 7) { solutionType ← "basic" } ELSE { solutionType ← "acidic" } } Which of these tables shows the expected values of solutionType for the given values of phLevel?

phLevel solutionType -0.4 "acidic" 4.7 "acidic" 6.9 "acidic" 7 "neutral" 7.4 "basic" 14.2 "basic"

Phoebe is holding a pie eating party and is writing a program to help her determine what ice cream to pair with each pie. IF (pie = "apple") { iceCream ← "caramel" } ELSE { IF (pie = "razzleberry") { iceCream ← "cinnamon" } ELSE { IF (pie = "peach") { iceCream ← "nutmeg" } ELSE { IF (pie = "plum") { iceCream ← "honey" } ELSE { iceCream ← "vanilla" } } } } Which of these tables shows expected values for iceCream after running this program with a variety of values for pie? Choose 1 answer:

pieiceCream "cherry""vanilla" "apple""caramel" "razzleberry""cinnamon" "coconut""vanilla" "peach""nutmeg" "raspberry""vanilla" "plum""honey"

Dario is writing an activity planner program to help him remember what physical activities to do each day. IF (today = "Monday") { activity ← "swimming" } ELSE { IF (today = "Tuesday") { activity ← "jogging" } ELSE { IF (today = "Thursday") { activity ← "juggling" } ELSE { IF (today = "Saturday") { activity ← "gardening" } ELSE { activity ← "none" } } } } Which of these tables shows expected values for activity after running this program with a variety of values for today?

today activity "Sunday" "none" "Monday" "swimming" "Tuesday" "jogging" "Wednesday" "none" "Thursday" "juggling" "Friday" "none" "Saturday" "gardening"

A programmer for a music company is developing a program to determine the highest level of certification for an album. The program needs to follow this table of thresholds for each certification level: Minimum albums sold Certification 500,000 gold 1,000,000 platinum 10,000,000 diamond The code segment below uses nested conditionals to assign the certification variable to the appropriate value, but its conditions are missing operators. certification ← "none" IF (albumsSold <?> 10000000) { certification ← "diamond" } ELSE { IF (albumsSold <?> 1000000) { certification ← "platinum" } ELSE { IF (albumsSold <?> 500000) { certification ← "gold" } } } Which operator could replace <?> so that the code snippet works as expected?

A programmer for an online store is developing a program to calculate discount pricing for bulk orders. The program needs to implement this pricing table: Minimum quantityDiscount105%757%15010% The code segment below uses nested conditionals to assign the discount variable to the appropriate value, but its conditions are missing operators. discount ← 0 IF (quantity <?> 150) { discount ← 10 } ELSE { IF (quantity <?> 75) { discount ← 7 } ELSE { IF (quantity <?> 10) { discount ← 5 } } } Which operator could replace <?> so that the code snippet works as expected?


Kaugnay na mga set ng pag-aaral

EMT Ch 37: Hazardous Materials, Multiple-Casualty Incidents, and Incident Management

View Set

Security+ SY0-601 Certification Practice Exam

View Set