A class Tach has a method rpm() that returns an integer. Consider the following
ID: 3643431 • Letter: A
Question
A class Tach has a method rpm() that returns an integer. Consider the following method from the same class.// precondition: 0 < caution < danger
// postcondition: return "green" if rpm is less than caution;
// return "yellow" if rpm is greater than or equal to caution and
// less than danger
// return "red" if rpm is greater than or equals to danger
public string indicator(int caution, int danger)
{
// missing code
}
The method indicator is intended to return "green" if rpm() returns a value less than caution, to return "yellow" if rpm()returns a value greater than or equal to caution and less than danger, to return "red" if rpm()returns a value greater or equal to danger.Consider the following replacement for //missing code.
I. if(rpm() < caution)
return "green";
else if(caution <= rpm() < danger)
return "yellow";
else
return "red";
II. if(rpm() < caution)
return "green";
if(rpm() >= danger)
return "red";
return "yellow";
III. if(rpm() < caution)
return "green";
else if(rpm() >= danger)
return "red";
else
return "yellow";
Which of these replacements for //missing code would make the method indicator work as intended?
Explanation / Answer
II and III
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.