CJCoding With Joseph
15per day

Count Valid Integers in a Loop

Read 5 lines of input. For each line, try to parse it as an integer. Count how many lines are valid integers and how many are invalid. At the end, print:

Valid: X
Invalid: Y

Use a loop with a try-catch inside.

⚠️ AUTO-INPUT MODE: The input stream will automatically contain '10\nabc\n3\nhello\n7\n'.

Expected Output:

Valid: 3
Invalid: 2
Topics:
Miscellaneous
📥 Auto-Input:
10\nabc\n3\nhello\n7\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.