Optional Questions You can earn one \"Class Activities\" extra credit point for
ID: 3738199 • Letter: O
Question
Optional Questions You can earn one "Class Activities" extra credit point for each question, but you must interact with Pat, Michael, or any of the TAs by Monday (March 26) at 6:00 pm. As a result of meeting with students, I need to add two more requirements: 1) Make sure you use self- documenting variables; x, y, z, i, j, k, or any single-letter variables won't work, and var1 or varA won't work either-the variables need to describe what they are; functions must also be self- documenting and should always start with a verb. 2) Please bring your solutions in on paper; we are finding that solutions brought in on laptops are a little hard to manage. 1) Write a function that accepts two numbers as parameters and returns the larger of the two 2) Write a function that accepts three numbers as parameters and returns the largest of the three; the function may not use any if statements, but must use the function generated in item #1 3) Write a function that returns true if two numbers accepted as parameters are equal; this function must also not use any if statements 4) Write a function called inBetween that accepts three parameters. If the first parameter is larger than the second parameter and smaller than the third parameter, the function must return true 5) Write a function called isNotRed that returns true if any color is passed in as a string parameter (e.g., "blue", "green", "orange" etc.) that is not "red"; if the string color passed in as a parameter is "red" the function must return falseExplanation / Answer
Solution:
The first four subparts have been answered as per Chegg guidelines, please repost others.?
1)
int largestOfTheTwo(int num1, int num2)
{
if(num1>num2) //comparing which one is greater
return num1;
else
return num2;
}
2)
int largestOfTheThree(int num1, int num2, int num3)
{
if(num1>num2) //comparing which one is greater
{
if(num1>num3)
return num1;
else
return num3;
}
else
return num2;
}
3)
int isEqual(int num1, int num2)
{
if(num2==num2)
return true;
else
return false;
}
4)
int inBetween(int num1, int num2, int num3)
{
if(num1>num2) //comparing which one is greater
{
if(num2>num3)
return num2;
else if(num1>num3)
return num3;
else
return num1;
}
}
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.