d) As you see, this whole program includes the following code segment which uses
ID: 3876047 • Letter: D
Question
d) As you see, this whole program includes the following code segment which uses a select...case block Select case position Case 1 txtoutput.text-" win" Case 2 trtoutput.text place" Case 3 txtoutput.text-" show Case 4,5 txtoutput.text- you almost placed in the money. Case else trtoutcome.text out of the money." End Select Please rewrite this code segment with an i..e.seif..e.nd if block instead of the select.case block, such that the program still works properly (Note: only this code segment other than the whole program needs to be rewritten).(8 points) Write your answer here):Explanation / Answer
I have converted that code segment with if.... elseif...end
CODE:
if(position == 1){ // Here condition will be true if the value of position will be 1
txtoutput.text = "win";
} else if(position == 2) { // Here condition will be true if the value of position will be 2
txtoutput.text = "place";
} else if(position == 3) { // Here condition will be true if the value of position will be 3
txtoutput.text = "show";
} else if(position == 4 || position == 5) { // Here condition will be true if the value of position will be 4 or 5
txtoutput.text = "you almost placed in the money";
} else { // Here condition will be true if the value of position will be not 1,2,3,4 or 5
txtoutput.text = "out of money";
}
If you have any query regarding this problem then please feel free to ask in comment.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.