Practice
Validated Stock Count Total
2024/May/June·Variant 1
EASYLoops
Read 4 stock counts, one at a time. Each count must be validated so that only values from 0 to 999 (inclusive) are accepted — reject and re-ask for anything outside that range. Output the total of the 4 valid counts.
Input: Stock count entries (some may be invalid and re-entered) until 4 valid values have been read.
Output: Total stock: <total>.
Example:
Input: 10
20
30
40
Output: Total stock: 100
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Four valid entries
Inputs: 10, 20, 30, 40
Expected: Total stock: 100
Test 2: A negative entry is rejected and re-entered
Inputs: -5, 10, 20, 30, 40
Expected: Total stock: 100