Respuesta :
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 * score
- score between 50 and 100 implies bonus = score
- score < 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
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