Area 06 · Control structures
Number tools menu
A menu-driven program that runs small number tools until the user exits, the classic shape of a hands-on console program.
- Spec no.
- HO-12
- Level
- Exam-level
- Time box
- 1 h 15 min
- Reference
- Java · C#
- Grading
- Self-assessed · rubric is ours, not DICT's
01 Coverage
| Area | Sub-skills practised | Role |
|---|---|---|
| 01 Data manipulation | Validation | Also |
| 06 Control structures | Conditional, Iteration | Primary |
Sign up to start coding practice
Read the task freely. An account is required before editing and running a solution. Code runs also need an internet connection.
Sign up or sign in02 Requirements
- Each line is a choice and a value: 1 n prime check, 2 n digit sum and reverse, 3 n multiplication table (n from 1 to 12, ten rows), 4 n centred pyramid of n rows (1 to 20).
- 0 prints Bye and ends the program; ignore anything after it.
- Any unknown choice, missing value, non-number or out-of-range value prints Invalid choice.
- Prime check must stop at the square root.
- Digit sum and reverse must use % and /, not string reversal.
- The pyramid uses nested loops: row r has n − r spaces and 2r − 1 stars.
03 Input and output
- Lines of choice value
- 0 to exit
- 29 is prime / 91 is not prime
- Digit sum s, reversed r
- Table rows n x i = p
- Pyramid rows
- Invalid choice / Bye
1 29
1 91
2 1204
4 3
9
4 abc
0
1 729 is prime
91 is not prime
Digit sum 7, reversed 4021
*
***
*****
Invalid choice
Invalid choice
ByeMatch the sample exactly first, then write at least two test inputs of your own.
04 Edge cases to test
- 1 0 and 1 1 (not prime)
- 2 1200 (reverse is 21)
- 3 13
- 4 abc
05 Starter outline and hints
loop over linesswitch(choice): 0 → Bye, return; 1..4 → validate value → run tooldefault → Invalid choice
Hint 1
In Java a labelled break leaves the loop from inside a switch; in C# a return or a flag does the same.
06 Practice rubric
| Criterion | Sub-skills | Look for | Pts |
|---|---|---|---|
| Menu control | ConditionalIteration | One loop, one dispatch, exit on 0, every bad input caught. | 30 |
| Prime and digits | Iteration | Square-root bound; arithmetic digit handling. | 30 |
| Nested loops | Iteration | Pyramid and table shapes exactly as specified. | 25 |
| Validation | Validation | Range checks per option. | 15 |
| Total | 100 | ||
Our own weighting for practice. It is not the DICT scoring scheme.
07 Self-check
Tick only what you have verified by running your own program.
Loading saved checks…
08 Reference solution
Both versions compiled and reproduced the sample output on Java 21 and .NET 8 when this site was built. Reference solutions are in Java and C#. The 2023 FAQ copy also lists C, C++ and Visual Basic 6.0 / .NET; the same structure carries over, but you will need your language's own file and database APIs.
Try the whole brief first. The reference is one correct approach, not the only one, and reading it early removes most of the practice value.
09 Exam-day habits
- Work without internet search to simulate exam conditions.
- Type the sample input yourself and compare your output line by line before you look at the reference.