int difference(int a, int b) {
---
void difference(int a, int b) { #paired
---
if (a - b > 0) {
---
if (a - b < 0) { #paired
---
return << a - b;
}
---
else {
---
return << -1;
}
---
}
According to a logic game, a knight is someone who cannot tell a lie, and a knave is someone who cannot tell the truth. Construct a function that takes two booleans: the truth value of the story, and the truth value told by the person. The function should print whether the person was a knight or a knave.
Write a function isNegative. It should take a single integer as its parameter and return true if the integer is negative or false if it is not. Includes and tests are present but hidden.
Write a function exclusiveOr. If a and b are both true or both false, it should return false. If one is true and the other is false, it should return true. Includes and tests are present but hidden.
Write a function exclusiveOr. If a and b are both true or both false, it should return false. If one is true and the other is false, it should return true. Includes and tests are present but hidden.
In a dice game, the player rolls two dice, one red and one blue. If the red die has a higher value, they score 0. If the blue one is higher, they score the value of the blue one minus the red one. If the two dice are the same, they score the value shown on the blue die.
Write a function computeScore. It should take two integers for redDie and blueDie (in that order) and return the score the player earns. Includes and tests are present but hidden.
Write a function gradePoints. It should take a single integer representing a percentage grade (0-100) and return the integer number of grade points that equates to. 0-59 should be 0 grade points, 60-69 1 grade point, 70-79, 2 grade points, 80-89 3 grade points, and 90+ 4 grade points. Includes and tests are present but hidden.
Write a function orderCost. It should take a single double representing the undiscounted order price and return the double value of what the order should cost. Includes and tests are present but hidden.
Write a function orderCost. It should take a single double representing the undiscounted order price and return the double value of what the order should cost. Includes and tests are present but hidden.
In a two-person card game, the players each start with 20 "health points" and play until one is reduced to 0 or less. If a player reduces the other to 0 health, they are the winner. If the winner still has 10 or more of their health points left, it is declared a "crushing win" (or "crushing loss" depending on your perspective).
Write a function to announce the results of a game. It should take as parameters the two integer health values for the players and print the outcome of the game from the perspective of player 1 (the first health value) - Win, Loss, Crushing Win, Crushing Loss. For example, if the two values were 8 and 0 you should print Win. If the two values were -1 and 16 you would print Crushing Loss. Includes and tests are present but hidden.