In a certain game, the integer variable bonus is assigned a value based on the value of the integer variable score.

• If score is greater than 100, bonus is assigned a value that is 10 times score.

• If score is between 50 and 100 inclusive, bonus is assigned the value of score.

• If score is less than 50, bonus is assigned a value of 0.

Which of the following code segments assigns bonus correctly for all possible integer values of

score ?

Select two answers.







A

IF(score > 100)

{

bonus score * 10

}

ELSE

{

IF(score ≥ 50)

{

bonus score

}

ELSE

{

bonus 0

}

}


B

IF(score ≥ 50)

{

IF(score > 100)

{

bonus score * 10

}

ELSE

{

bonus 0

}

}

ELSE

{

bonus score

}

Answers

Answer 1

Answer:

See Explanation

Explanation:

The options are not properly presented; hence, they can't be used to answer this question

First, we need to analyze the conditions:

score > 100 implies bonus = 2 * scorescore between 50 and 100 implies bonus = scorescore < 50 implies bonus = 0

Writing the above as programming instructions, we have:

if(score > 100){//This represents the first condition

bonus = 2 * score;

}

else if(score >=50 && score<=100){//This represents the second

bonus = score;

}

else{//This represents the last condition

bonus = 0;

}

Note that, we assume that all variables have been declared

The comments (//) were used for explanation purpose

Answer 2

Following are the conditional statement code to the given conditions:

Code Explanation:

In the given code, nested If-else statement is declared that checks the score value.

In the first code,  an if block is used that checks "score" value greater than 100, if its true a "bonus" variable is defined that multipling the score value with 100 and store its value.Otherwise it will go to else block in this another if block is defined that checks score value greater than equal to 50.When its true it stores score value in bonus variable, otherwise it initialize the bonus value with 0.In the second code,  an if block is used that checks "score" value less than 50, if its true a "bonus" variable initialize with the 0.Otherwise it will go to else block in this another if is defined that checks score value greater than 100, if its true it multiples the score value with 10 and store its value in bonus variable. In the else block it stores the score value in bonus variable.

Code :

First code:

IF(score > 100) //defining an if block that checks score value greater than 100

{  

bonus =score* 10//multipling the score value with 100 and store its value in bonus variable  

}  

ELSE //defining else block

{  

IF(score >=50) //defining another if block that checks score value greater than equal to 50

{  

bonus= score //storing score value in bonus variable

}  

ELSE //defining ELSE block

{  

bonus =0//holing value 0 in bonus variable

}

}

Second code:

IF(score < 50) //defining an if block that checks score value less than 50

{  

bonus =0 //Initializing the value 0 in bonus variable

}

ELSE //defining ELSE block

{  

IF(score > 100) //defining an if block that checks score value greater than 100

{  

bonus= score *10 //multipling the score value with 10 and store its value in bonus variable  

}

ELSE //defining ELSE block

{  

bonus = score  //storing score value in bonus variable

}

}

Learn more:

brainly.com/question/17088643


Related Questions

Other Questions
Reasons why God exists or not from the video Big Questions: Does God Exist?OF THE VIDEO!!! Which task can be completed with the Template Organizer?A. grouping templates based on categoriesB. adding styles from one template to anotherC. listing template names in ascending orderD. defining the numbering properties of templates The central atom in an amino acid that all the groups connect to is aO A. Hydrogen.O B. Oxygen O C. Carbon.O D. Nitrogen Factor.2m2 + 7m - 9 Define energy and power and describe the relationship that exists between them. Explain how this relationship affects machines or other systems. (1 point)Your answer should be in complete sentences that describe and explain both questions.Be sure to check your grammar and spelling. and them is the pic At a little-known vacation spot, taxi fares are a bargain. A 16-mile taxi ride takes 24 minutes and costs $9.60. You want to find the cost of a 42-minute taxi ride. What unit price do you need? Describe how and why Theodore Roosevelt was described as the first Progressive president What does the xylem do? A .stores the glucoseB captures the sunlightC absorbs oxygen into the leaf D carries water from the roots to the leaves !HELP! PLEASE ANSWER WILL MARK BRAINLIEST! 50 POINTS!Common leavening agents include all of the following EXCEPTSaltYeastBaking Soda & Baking PowderAir & Eggs Please answer these and I will give brainliest!!!Use dimensional analysis to convert each rate. Round your answer to the nearest hundredth if necessary.#1. A cyclist travels 56 miles in 4 hours. Find the cyclist in feet per minute.#2. Lebron James', contract is rumored to be around 430,000,000 per year. Convert this to dollars per minute.#3. A giraffe can run 32 miles per hour. What is their speed in feet per second? What is the formula for calculating a residual value Compare and contrast absolute rule in France, Russia, and Prussia. Use evidence from the lesson and the reading to support your co A pure market economy is based on the interaction of _______ and _______.1. Buyers and Sellers2. Buyers and Consumers3. Sellers and producers4. Producers and distributersPlease help! common factors of 128 and 192 she is planning to on atour ..?? write to him\ her Describe the nitrogen cycle in your own words and how the nitrogen cycles through our Earth. how do I save something to a flashdrive on powerpoint why will water and oil not mix? A forest covers 71,000 acres. A survey finds that 0.3% of the forest is old-growth trees. How many acres of old-growth trees are there? By the end of Act 2 Hamlet realizes he's been betrayed. What should he do now that he's discovered the deception?