Programs need selection to be anything more than a linear process, and to make those selections boolean expressions are required. A boolean expression is a logical statement that evaluates to a boolean value (true
or false
). Boolean expressions allow logic to be added to code that provides conditional execution of sets of instructions (blocks of code). To create boolean expressions relational operators are combined with logical operators to form complex expressions.
Relational operators are operators that allow relational comparisons to be made in a program. Relational operators are binary operators which have two operands to make the relational comparison between. In C++ there are 6 relational operators:
Operator | Description | Notes |
---|---|---|
== | equal to | true if both sides are equivalent |
!= | not equal to | true if both sides are inequivalent |
< | less than | true if the lhs is less than the rhs |
<= | less than or equal to | true if the lhs is less than or equal to the rhs |
> | greater than | true if the lhs is greater than the rhs |
>= | greater than or equal to | true if the lhs is greater than or equal to the rhs |
Which work as they do in math when working with numerical values such as integers and floating-points:
Expression | Meaning | Value |
---|---|---|
6 == 6 | 6 is equal to 6 | true |
6.7 == 6.8 | 6.7 is equal to 6.8 | false |
6.7 != 6.8 | 6.7 is not equal to 6.8 | true |
6 != 6 | 6 is not equal to 6 | false |
6 < 7 | 6 is less than 7 | true |
7 < 6 | 7 is less than 6 | false |
6.7 < 6.7 | 6.7 is less than 6.7 | false |
6.7 <= 6.7 | 6.7 is less than or equal to 6.7 | true |
7.7 > 6.7 | 7.7 is greater than 6.7 | true |
6.7 > 7.7 | 6.7 is greater than 7.7 | false |
7 > 7 | 7 is greater than 7 | false |
7 >= 7 | 7 is greater than or equal to 7 | true |
And in characters as the ASCII value can be compared:
Expression | ASCII Values | Meaning | Value |
---|---|---|---|
‘a’ == ‘a’ | ‘a’ => 97 | 97 == 97 | true |
‘a’ == 65 | ‘a’ => 97 | 97 == 65 | false |
‘a’ != 65 | ‘a’ => 97 | 97 != 65 | true |
97 != ‘a’ | ‘a’ => 97 | 97 != 97 | false |
‘A’ < ‘a’ | ‘A’ => 65, ‘a’ => 97 | 65 < 97 | true |
‘b’ < ‘A’ | ‘b’ => 98, ‘A’ => 65 | 98 < 65 | false |
‘b’ < ‘b’ | ‘b’ => 98 | 98 < 98 | false |
‘b’ <= ‘b’ | ‘b’ => 98 | 98 <= 98 | true |
‘b’ > ‘A’ | ‘b’ => 98, ‘A’ => 65 | 98 > 65 | true |
‘S’ > ‘z’ | ‘S’ => 83, ‘z’ => 122 | 83 > 122 | false |
‘z’ > ‘z’ | ‘z’ => 122 | 122 > 122 | false |
‘z’ >= ‘z’ | ‘z’ => 122 | 122 >= 122 | true |
But for strings the relational operators are not so simple. For example consider the comparison:
”carl” < “Aaron”
Which naively can be taken as true
as ”carl”
has fewer characters than ”Aaron”
, but strings are not comparing lengths, rather they are performing a lexicographical ordering. A lexicographical ordering is an ordering based on ASCII values. It is very similar to alphabetizing where you are trying to see if one string comes before another. But rather than just simply not caring about capitalization and doing the comparison based solely on the alphabet, now capitalization matters so the ordering is done based on ASCII values. Thus, to perform relational comparisons on strings it is very similar to alphabetizing where you go to the first mismatched character and determine the order solely based on this character, now just add in capitalization to the ordering. Thus to do the previous comparison ”carl” < “Aaron”
the first mismatched characters ’c’
and ’A’
must have their ASCII values, 99 and 65 respectively, compared as 99 < 65
which is false
.
Thus, to perform string relations:
Compare characters from left to right until a mismatch is found or until the end of one (or both) strings is reached.
If a mismatched character is found, the comparison result of those two characters determines the string relation.
If no mismatches are found:
Using this algorithm, each of the relational operators can be used to compare strings:
Expression | First Mismatch | ASCII/Length Comparison | Value |
---|---|---|---|
“UNLV” == “UNLV” | None | length 4 == length 4 | true |
“UNLV” == “UNLV CS” | None | length 4 == length 7 | false |
“UNLV” == “UNR” | ‘L’ & ‘R‘ | 76 == 82 | false |
“UNLV” != “UNR” | ‘L’ & ‘R‘ | 76 != 82 | true |
“UNLV” != “UNLV CS” | None | length 4 != length 7 | true |
“UNLV” != “UNLV” | None | length 4 != length 4 | false |
“Disney World” < “Disneyland” | ‘ ’ & ‘l‘ | 32 < 108 | true |
“Tokyo Disney” < “Disney World” | ‘T’ & ‘D’ | 84 < 68 | false |
“Disneyland” < “Disney” | None | Size 10 < Size 5 | false |
“Disney” < “Disneyland” | None | Size 5 < Size 10 | true |
“Disneyland” < “Disneyland” | None | Size 10 < Size 10 | false |
“Disneyland” <= “Disneyland” | None | Size 10 <= Size 10 | true |
“Mickey” > “Goofy” | ‘M’ & ‘G‘ | 77 > 71 | true |
“Mickey” > “Minnie” | ‘c’ & ‘n‘ | 99 > 110 | false |
“Min” > “Minnie” | None | Length 3 > Length 6 | false |
“Minnie” > “Mick” | None | Length 6 > Length 4 | true |
“Minnie” > “Minnie” | None | Length 6 > Length 6 | false |
“Minnie” >= “Minnie” | None | Length 6 >= Length 6 | true |
The relational operators can be used in combination with arithmetic through basic arithmetic and <cmath>
functions. For strings the only arithmetic operator is +
which is concatenation resulting in a new string, so simply do the concatenation prior to the relation. For example:
”Han” + “ “ + “Solo” > “Yoda”
Would first need the concatenation to be performed, otherwise, which value on the left side would be compared to “Yoda”? So the concatenation is performed:
”Han Solo” > “Yoda”
Which has a mismatch on the first 2 characters causing the comparison 72 > 89
which is false
.
On the other hand, the numerical values have more arithmetic that can be performed on them, and that arithmetic has precedence to it. Added to that, what about if there are multiple relations in a single expression, which goes first? For example if a shipping company wants to upcharge packages with a weight:volume ratio of more than 50%, so they want to make that comparison and save its results into a variable the following expression could be performed:
double weight = 2.5, volume = 5; bool exceedsRatio = weight / volume > .5;
The operators =
/
/ and >
will be formed in the following precedence:
Precedence | Operators | Description |
---|---|---|
1 | () | Parenthesis (Functions) |
2 | * / % | Multiplication, Division, Modulus |
3 | + - | Addition, Subtraction |
4 | < <= > >= | Less Than/Equal To, Greater Than/Equal To |
5 | == != | Equal, Not Equal |
6 | = | Assignment (Compound Assignment) |
Since the relations are being performed on actual values, not operations on values, they need the mathematical operations to be resolved first, thus PEMDAS is first followed. Then the relations can be solved with less/greater than and their equivalency cases on the same level, followed by the equal and not equal cases. The assignment operator has the lowest precedence as it gets assigned the final value of whatever expression is on the right of it.
Write a program that outputs
0
(false
) if a user enters a username that is not”chewbacca”
, otherwise outputs1
(true
).
First user input of a username must be read into a string:
#include <iostream> using namespace std; int main() { // variables string username = “”; const string REQUIRED_USERNAME = “chewbacca”; // get username cout << “Username: “ getline(cin, username); return 0; }
The username is being read into a string
variable thus getline()
must be used to read the input as there may be spacing in the username. The username can then be checked against the REQUIRED_USERNAME
using the ==
(equivalency) operator and the result of the relational expression output:
#include <iostream> using namespace std; int main() { // variables string username = “”; const string REQUIRED_USERNAME = “chewbacca”; bool usernameCorrect = false; // get username cout << “Username: “ getline(cin, username); // check if username is correct usernameCorrect = username == REQUIRED_USERNAME; // output results cout << usernameCorrect << endl; return 0; }
The order of operations is followed first performing username == REQUIRED_USERNAME
which will only be true
if the user enters “chewbacca”
exactly, otherwise it will be false
. The value is then stored into the boolean variable usernameCorrect
using the assignment operator. The variable is then output, which causes 0
to be output for false
and 1
to be output for true
.
Logical operators are operators that combine or modify boolean expressions. Logical operators can be either unary operators that only operate on a single operand, or binary operators which operate on two operands. In C++ there are 3 logical operators:
Operator | Description | Notes |
---|---|---|
! | Logical Not | Negates the operand |
&& | Logical And | true only if both operands are true |
|| | Logical Or | true if at least one operand is true |
Which are added to the precedence table with !
having the second highest level of precedence, with &&
having precedence over ||
just before assignment:
Precedence | Operators | Description |
---|---|---|
1 | () | Parenthesis (Functions) |
2 | ! | Logical NOT |
3 | * / % | Multiplication, Division, Modulus |
4 | + - | Addition, Subtraction |
5 | < <= > >= | Less Than/Equal To, Greater Than/Equal To |
6 | == != | Equal, Not Equal |
7 | && | Logical AND |
8 | || | Logical OR |
9 | = | Assignment (Compound Assignment) |
!
To flip the boolean value of any boolean expression the unary logical NOT operator is used !x
where x
is the boolean expression to flip the value of (negate). Thus, for any boolean expression, its negation follows the following truth table:
x | !x |
---|---|
true | false |
false | true |
For example, to create a boolean expression that a bar could use to check if someone is 21 by getting false
if they are 21 and true
if they are not 21 the bar could check if the person is 21 or older, then negate the result:
int age = 20; bool not21 = !(age >= 21);
The age > 21
must be surrounded with parentheses because !age > 21
causes !
to take precedence over >=
. This causes !age
be evaluated which will be true (1) if age
is 0
as 0
is false and that false negated gives a true, and false (0) if age
is any other value because any value other than 0
is true
. Thus !age
would only ever resolve to 0
or 1
causing the second part of the expression result >= 20
to always evaluate to false
. With the way the expression read as written age >= 21
is properly run first as parenthesis have the highest priority, making the proper age comparison, then the result of that comparison is negated.
&&
Two boolean expressions can be combined together using the binary logical AND operator x && y
where the x
and y
operands are both separate boolean expressions.The logical AND produces a boolean result which is true
only if both operands are true
which can be seen from the truth table:
x | y | x && y |
---|---|---|
true | true | true |
true | false | false |
false | true | false |
false | false | false |
For example, if in a video game a player has to have enough runes and high enough level to cast a spell, then a boolean expression can be written that tests the rune count and player level are high enough to cast a spell:
int runeCount = 20, level = 25, runeCost = 5, fireBoltLvlReq = 35; bool canCast = runeCount >= runeCost && level >= fireBoltLvlReq;
Here the order of operations is followed causing the two >=
to be evaluated. If either the runeCount
or level
are too small they will cause the respective side of the &&
to be false
causing canCast
to be false
, such as what happens in the example with level
being too low (25 < 35
). Otherwise, if both runeCount
and level
are large enough (such as if the values were being read in so they change) then canCast
will be true
.
If there were more requirements to cast, such as if there were multiple types of runes, say fire/air/chaos, that needed to be used to cast, then more logical AND operations can be strung together. Then, when evaluating the expression the leftmost &&
can be evaluated, and its result passed to the next &&
and so forth until they are all worked through.
int airCount = 15, fireCount = 20, chaosCount = 5; level = 25, airCost = 3, fireCost = 4, chaosCost = 1, fireBoltLvlReq = 35; bool canCast = airCost >= airCount && fireCost >= fireCount && chaosCost >= chaosCount && level >= fireBoltLvlReq;
Here, all of the relations are evaluated resulting in true && true && true && false
and then the &&
s are evaluated left to right. So true && true
evaluates to true
, which is passed to the next &&
for true && true
which evaluates to true
, which is passed to the next &&
for true && false
which evaluates to false
.
If however level
were 35
or larger, then the final relation would be true
making the final logical comparison be true && true
which would evaluate to true
.
||
Two boolean expressions can also be combined together using the binary logical OR operator x || y
where the x
and y
operands are both separate boolean expressions.The logical OR produces a boolean result which is true
if at least one operand is true
which can be seen from the truth table:
x | y | x || y |
---|---|---|
true | true | true |
true | false | true |
false | true | true |
false | false | false |
For example, a video game may use a boolean expression to have a room only for players that have completed a certain amount of quests or that have passed a level threshold:
int questCount = 20, level = 25, questsNeeded = 10, requiredLevel = 35; bool canCast = questCount >= questsNeeded || level >= requiredLevel;
Here, if the player has completed enough quests the left hand side of the ||
will be true, if the player is high enough level the right hand side of the ||
will be true, and if enough quests have been completed and the player is high enough level both sides will be true. In all 3 cases the player would be let into the room. But, if the player hadn’t completed enough quests and was not high enough level, then both sides would be false
, allowing the program to know not to let the player into the room.
Like the logical AND multiple logical ORs can be strung together to make more complex statements, which are evaluated left to right. But what if the player needed to have not only enough quests or high enough level, but also had to have enough gold to enter. A boolean expression could be written:
int questCount = 20, level = 25, gold = 100 questsNeeded = 10, requiredLevel = 35, requiredGold = 1000; bool canCast = questCount >= questsNeeded || level >= requiredLevel && gold >= requiredGold;
But there is a problem with this expression. The &&
takes precedence over the ||
so in this case level >= requiredLevel && gold >= requiredGold
would be evaluated first, making the player have to have enough gold and enough required level for this statement to be true
. The value from the logical AND would then be passed to questCount >= questsNeeded || y
which would be true if the quest count was high enough, or if the logical AND was true. This is incorrect because this would mean to get into the room the player needs either enough quests, or high enough level and gold. The gold would only matter if the player wasn’t high enough level (which might be how some games work but not this one). To force the logical OR to be performed prior to the logical AND the logical OR simply needs to be surrounded with ()
:
int questCount = 20, level = 25, gold = 100 questsNeeded = 10, requiredLevel = 35, requiredGold = 1000; bool canCast = (questCount >= questsNeeded || level >= requiredLevel) && gold >= requiredGold;
Since parenthesis have the highest precedence the expression inside of them, the logical OR, will be run first, with its value then passed to the logical AND. Since the logical OR now runs first the meaning get changed to the player either has the required quest count or level, and enough gold.
Short Circuit Evaluation is when a logical expression stops being evaluated as soon as the final truth value can be determined. Consider the truth table for the logical AND and OR for when the logical AND gets false
first:
x | y | x && y |
---|---|---|
false | true | false |
false | false | false |
And the logical OR gets true
first
x | y | x || y |
---|---|---|
true | true | true |
true | false | true |
In both cases the truth value of the second operand y
does not matter, the value of the logical operation can be determined with just the first operand x
. For the logical AND when the first operand is false
the operation is guaranteed to be false
since both sides must be true
for logical AND to be true
. Similarly, for the logical OR when the first operand is true
the operation is guaranteed to be true
since only one side must be true
for the logical OR to be true
. This is not the case for the logical AND:
x | y | x && y |
---|---|---|
true | true | true |
true | false | false |
And the logical OR:
x | y | x || y |
---|---|---|
false | true | true |
false | false | false |
When the logical AND is true
for the first operand, then the expression is a candidate for being true
. This forces the second operand to be evaluated to know the result of the operation. For the logical OR this is the case when the first operand is false
.
In Disneyland when new rides open park management uses an automated queue system that places people that join into the queue into groups starting at group 1 through whatever number park management chooses (80/100/200/etc.). The system then calls groups back working linearly through the group numbers at times chosen by management throughout the day.
The park is currently admitting parkgoers to a new ride that are in group 10 or less, and that have waited 60 minutes. Write a program that outputs
0
(false
) when a user enters in a boarding group and time waited lower than the current thresholds, and1
(true
) otherwise.
First user input of what boarding group the parkgoer is in as well as how long they have waited must be read into integers:
#include <iostream> using namespace std; int main() { // variables int group = 0, timeWaited = 0; // get group cout << “Group: “ cin >> group; // get time waited cout << “Time Waited: “ cin >> timeWaited; return 0; }
The username is being read into a string
variable thus getline()
must be used to read the input as there may be spacing in the username. The username can then be checked against the REQUIRED_USERNAME
using the ==
(equivalency) operator and the result of the relational expression output:
int main() { // variables int group = 0, timeWaited = 0; const int CURRENT_GROUP = 10, CURRENT_WAIT = 60; bool canRide = false; // get group cout << “Group: “ cin >> group; // get time waited cout << “Time Waited: “ cin >> timeWaited; // check if it is the parkgoer’s turn to ride canRide = group <= CURRENT_GROUP && timeWaited >= CURRENT_WAIT; // output results cout << canRide << endl; return 0; }
Since the relational operators have precedence over the logical AND group <= CURRENT_GROUP
and timeWaited >= CURRENT_WAIT
get run first, which pass their results to the logical AND to get its result.
This is not the only way to get on the ride in the first few opening weeks, you can always pay to get on the ride immediately (lets call it a fast pass).
Add to the program asking if the parkgoer has a fastpass, and have
1
(true
) also be output when the parkgoer has a fastpass.
Input can be read in for a boolean regarding if the parkgoer has a fastpass:
int main() { // variables int group = 0, timeWaited = 0; const int CURRENT_GROUP = 10, CURRENT_WAIT = 60; bool canRide = false, hasFastpass = false; // get group cout << “Group: “ cin >> group; // get time waited cout << “Time Waited: “ cin >> timeWaited; // get fastpass status cout << “Fast Pass (0 if none, otherwise any other value): “ cin >> timeWaited; // check if it is the parkgoer’s turn to ride canRide = group <= CURRENT_GROUP && timeWaited >= CURRENT_WAIT || hasFastpass; // output results cout << canRide << endl; return 0; }
The check for having a fastpass simply needs to be added with a logical OR with no parenthesis needed. This is because the logical AND takes precedence over the logical OR. Thus the logical OR being added can not mess up the logical AND (as long as the logical OR is not added in the middle of the logical AND as one of its operands) no matter what side of the current logical expression it is added to. So if the parkgoer is in the non-paying group that has to wait then the left hand side of the ||
will be true
, and if the parkgoer is in the paying group that does not have to wait then the right hand side will be true
. Thus, if the parkgoer is in either group the expression will be true
, otherwise if the parkgoer is in neither group the expression will be false
.
Boolean Expression - A logical statement that evaluates to a boolean value (true
or false
).
Relational Operator - An operator that allows relational comparisons to be made in a program.
Logical Operator - An operator that combines or modifies boolean expressions.
Short Circuit Evaluation - When a logical expression stops being evaluated as soon as the final truth value can be determined.
See individual relational and logical operators above.
What is a Boolean expression?
Name the six relational operators in C++.
What does the ==
operator do?
What is the difference between ==
and !=
?
What is tested by the <
operator?
How does <=
differ from <
?
What does >=
check?
Give an example of a true
relational expression using integers.
Give an example of a false
relational expression using floating-point values.
Can characters be compared using relational operators? Explain.
Do relational operators work the same on strings as integers?
Explain how string comparisons are performed in C++.
When two strings match up to one’s length but one is shorter, how is that evaluated?
Give a string comparison example that evaluates to true.
What is operator precedence when both arithmetic and relational operators are used?
In weight / volume > 0.5
, which operation is done first?
List the precedence order: multiplication and division, relational, equality, assignment.
What are the three logical operators in C++?
How does the logical NOT (!
) operator work?
When combining &&
and ||
, which has higher precedence?
Explain short-circuit evaluation for &&
.
Explain short-circuit evaluation for ||
.
What is wrong with writing !age > 21
instead of !(age >= 21)
?
In the Disneyland ride example, what boolean expression determines whether someone can ride?
In the Disneyland ride example, what change adds "fast pass" functionality to the ride logic?
Define “short-circuit evaluation” in your own words.
Evaluate: 3 < 8
Evaluate: 10 >= 10
Evaluate: 5 != 5
Evaluate: 'x' > 'a'
(ASCII)
Evaluate: "Apple" < "apple"
(lexicographically)
Evaluate: "Disney" != "Disneyland"
Evaluate: 7 <= 6
Evaluate: 2 + 3 * 4 == 14
Evaluate: (8 / 2) >= 4
Evaluate: 5 * (2 + 3) != 25
Evaluate: 7 - 2 < 3 + 1
Evaluate: 10 % 3 == 1
Evaluate: 6.0 * 2 > 11.9
Evaluate: 5 < 10 && 2 + 2 == 4
Evaluate: 7 >= 7 || 3 > 5
Evaluate: 3 != 3 && 4 < 5
Evaluate: 10 > 2 || 8 < 3
Evaluate: 4 + 1 == 5 && 6 - 2 >= 3
Evaluate: 1 + 1 == 2 && 2 * 2 == 5
Evaluate: (2 + 3) * 2 != 10 || 0 == 1
Evaluate: 5 > 3 && (4 + 4) >= 8
Evaluate: (7 - 2) == 5 || 10 / 2 < 5
Evaluate: 2 * (3 + 1) > 8 && 9 / 3 == 3
Evaluate: 1 + 1 == 2 || (2 * 2 != 4 && 0 < 1)
Evaluate: (5 >= 5 && 3 < 2) || (4 - 1 == 3)
int a = 7.5, b = 3.0; bool c = a / b > 2.0 && b == 3;
What is the result of c
?
int x = 5, y = 2; bool z = x / y == 2 && x % y == 1;
What is the result of z
?
int a = 10, b = 3; bool c = a / b + 2 > 4 && b == 3;
What is the result of c
?
char c1 = 'A', c2 = 'a'; bool b = c1 < c2 && (c2 - c1) == 32;
What is the result of b
?
bool s = string("Zoo") < string("apple") || string("cat") < string("dog");
What is the result of s
?
int a = 9, b = 2; bool r = a / b == 4.5 || a / b == 4;
What is the result of r
?
int age = 20; bool check = !age > 18;
What is the result of check
?
int a = 5, b = 0; bool safe = b != 0 && a / b > 1;
What is the result of safe
?
int a = 5; bool b = (a = 3) == 3;
What is the result of b
? What is the new value of a
?
int a = 4, b = 5; bool result = a + b / 2 > 6 && (a * b) % 2 == 0;
What is the result of result
?
In the following questions, you are given real-world scenarios described in plain English. Your task is to translate each situation into a boolean expression using the relational and logical operators you have learned. Be careful to capture the conditions exactly as stated, and use parentheses when needed to make the order of evaluation clear. Your solution should be just variables and a boolean expression with no selection structures.
In a video game, a player can open a chest if they have at least three keys and their health is greater than fifty.
At Disney World, a guest can enter a ride if their group size is ten or fewer, or if they have a fast pass.
A gamer levels up if their experience points are one thousand or more and they have completed at least five quests.
A student earns an A grade if their score is ninety or higher, or if their score is at least eighty and they also earned five or more points of extra credit.
A Disney app visitor is flagged if they are a guest and their visit count is greater than one thousand.
A game allows a combo move if button A is pressed and either button B or button C is also pressed.
A pirate ride can be boarded if the rider is taller than forty-eight inches and they either have a VIP pass or have waited more than thirty minutes.
At the arcade, a player can start a game if they have two or more tokens and also have credits remaining.
A gamer can craft a potion if they have at least two herbs and also either water or magic dust.
In a Disney app, fireworks will show if the time is eight p.m. or later and it is either the weekend or a special event.
A character can enter the dungeon if their level is ten or higher and their health is greater than twenty, or if they have a magical shield.
A player can trade if they have at least five gold coins, or if they possess a rare item and are not banned.
A guest gains photo access if they are a photo pass holder and they have completed either ride three or ride five.
A shopkeeper sells a potion if the player’s level is five or higher and they also have at least fifty gold.
A ride operator sends an alert if there are more than one hundred guests in line and the wait time is longer than sixty minutes, or if the ride status is closed.
A bonus activates if the player’s score is an exact multiple of one hundred and their level is greater than ten.
A guest qualifies for a free souvenir if they stayed more than five days or spent at least five hundred dollars.
A new track is unlocked in a racing game if the player has completed at least five laps and their best time is under one hundred and twenty seconds.
A Disney character appears if the season is Halloween and the current time is six p.m. or later.
A video game boss appears if the player either has the key or solved the puzzle, and they have not defeated the boss before.
A roller coaster only allows riders if their total group weight divided by the number of people is less than 200 pounds.
A student passes a course if their average score (total points divided by number of assignments) is 70 or higher.
In a video game, a character can unlock a gate if their attack power (base attack + weapon bonus) is at least 50.
At Disney World, a family gets a discount if the total ticket price (number of tickets × ticket cost) is greater than or equal to $500.
A runner qualifies for the finals if their time divided by laps completed is less than 5 minutes per lap.
A gamer can craft an item if the total resource value (wood × 2 + stone × 3) is at least 50.
A player wins a bonus if their total score (kills × 100 + assists × 50) is 1000 or higher.
A person qualifies for a contest if their age plus their years of membership is greater than or equal to 30.
A ride operator can allow entry if the average height of the group (total height ÷ number of riders) is at least 48 inches.
A video game boss fight unlocks if the sum of a player’s health and armor points is greater than twice the boss’s level.