You can now choose between two paths with if/else. What about three? A session may be short, standard, or extended depending on its duration. One test for “short” leaves two possibilities in else, so that alternative needs another decision.
Use else if to ask that next question only when the earlier condition was false. Keep all three choices in one chain so the session receives one label, rather than letting independent if statements overwrite it.
#include <iostream>
#include <string>
int main() {
int minutes = 50;
std::string length = "Pending";
if (minutes < 30) {
length = "Short";
} else if (minutes < 90) {
length = "Standard";
} else {
length = "Extended";
}
std::cout << length << "\n";
return 0;
}
This prints Standard. The first test fails. The second succeeds, so its block runs and the rest of the chain is skipped. At most one block in this chain runs.
The second condition does not repeat minutes >= 30. Reaching it already tells us the first condition was false. Together, the earlier failure and the new test define the middle range. The final else covers everything left over.
Order the thresholds carefully. If you checked minutes < 90 first, a ten-minute session would enter that branch and never reach a later short-session test. Start with the lowest upper boundary when building these increasing ranges.
Your task sorts a nonnegative age into an event category. The supplied conditions already separate ages below 13, ages from 13 through 17, and ages at least 18. Read those conditions before filling the branch bodies. Each TODO needs an assignment to category, not another condition; unfinished branches can keep the temporary "Pending" result.
The supplied for line repeats the decision for ages 12 through 18. It is a probe, not code you need to write yet; loops come in the next section. Leave it unchanged and edit only the branch bodies. This checks both sides of each boundary rather than one convenient age.
if block, assign "Child" to category. Expect Age 12: Child.else if block, assign "Teen" to category. Ages 13 through 17 should each report Teen.else block, assign "Adult" to category. Expect Age 18: Adult.Edit main.cpp, press Run to inspect the Console, then Submit to check these results.