★★★★★
"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."
Ria Mukherjee
Parent
ICSE Class 10 · Computer Applications (Java) · Menu driven programs 2027
A menu driven program in Java for ICSE shows the user a numbered or lettered list, reads a choice and uses switch to run only the matching task. The marks go to a fixed shape: menu, input, one case per option with its break, and a default case for a wrong choice. This page gives that shape as a five-part Section B template, then four full programs that each add one new idea, all run in Java 21 with the real output. In our live mini batch, students write menus to this template until it is automatic.
Live online · a five-part Section B template · four full menu programs · switch case questions · first class free
Start here
The ICSE Java course in which the mini batch writes these menus, the Class 11 and 12 Computer Science course where menus grow into larger ISC programs, and the data structures course for a student who wants to see how a menu becomes the front of a real application.

The batch / ICSE CA
Class 9 and 10 Computer Applications in a mini batch, where menu programs are written to one template and every wrong choice is tested.
Open the course →
Next step / ISC
For students moving to ISC Computer Science, where menus front longer programs on arrays, strings and objects.
Open the course →
Beyond the syllabus / DSA
For the student who likes building menus and wants to see stacks, queues and lists driven the same way.
Open the course →Ans. The short version
A menu driven program in Java for ICSE Class 10 prints a list of options, reads the user's choice with Scanner, and uses a switch statement to run only the code for that choice. A full-mark Section B answer has five parts: the printed menu, the choice read in, one case per option, a break ending every case, and a default case printing a message such as "Invalid choice" for any other input. Stacked labels let 'A' and 'a' share code. Modern Age Coders teaches this live in a Tuesday and Wednesday mini batch in India, or one to one at the family's time.
Q1. What should a menu driven answer look like in Section B?
Write the same five parts every time, whatever the options do. The examiner looks for each part, and a missing default case or a missing break is the commonest way to drop marks on an otherwise working menu.
| Part | What to write | Why it matters |
|---|---|---|
| 1. The menu | One System.out.println per option, numbered or lettered exactly as the question words them | The user, and the examiner, must see what each choice does |
| 2. The choice | int ch = sc.nextInt(); or char ch = sc.next().charAt(0); | The type of ch decides how the case labels are written |
| 3. One case per option | case 1: followed by the full logic for that option, including its own input | Each option is a small program; read only the data that option needs |
| 4. A break per case | break; as the last line of every case | Without it, control falls into the next case and runs that code too |
| 5. The default case | default: System.out.println("Invalid choice"); | The question almost always says "for an incorrect choice, display an appropriate message"; this is that message |
import java.util.Scanner;
class TempMenu {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("1. Celsius to Fahrenheit"); // part 1: menu
System.out.println("2. Fahrenheit to Celsius");
System.out.print("Enter your choice: ");
int ch = sc.nextInt(); // part 2: choice
switch (ch) {
case 1: // part 3: one case per option
System.out.print("Temperature in Celsius: ");
double c = sc.nextDouble();
double f = 9.0 / 5 * c + 32;
System.out.println("In Fahrenheit = " + f);
break; // part 4
case 2:
System.out.print("Temperature in Fahrenheit: ");
double fa = sc.nextDouble();
double ce = 5.0 / 9 * (fa - 32);
System.out.println("In Celsius = " + ce);
break;
default: // part 5
System.out.println("Invalid choice");
}
}
}
9.0 / 5 is written with a decimal point on purpose. 9 / 5 in int arithmetic is 1, and every answer in case 1 would be wrong.
| Variable | Type | Purpose |
|---|---|---|
| ch | int | menu choice entered by the user |
| c, f | double | Celsius input and Fahrenheit result (case 1) |
| fa, ce | double | Fahrenheit input and Celsius result (case 2) |
| sc | Scanner | reads keyboard input |
1. Celsius to Fahrenheit 2. Fahrenheit to Celsius Enter your choice: 2 Temperature in Fahrenheit: 98.6 In Celsius = 37.0 1. Celsius to Fahrenheit 2. Fahrenheit to Celsius Enter your choice: 1 Temperature in Celsius: 37 In Fahrenheit = 98.60000000000001 1. Celsius to Fahrenheit 2. Fahrenheit to Celsius Enter your choice: 3 Invalid choice
The long tail on 98.60000000000001 is how a double stores 1.8; it is correct Java output, not a bug. Always show one run that reaches the default case when you test a menu.
Q2. How do you write a menu with letters instead of numbers?
Read the choice as a char with sc.next().charAt(0) and put each letter in single quotes. To accept both capital and small letters, stack two labels on one block: case 'G': case 'g':. This is deliberate fall-through, the one place it helps.
import java.util.Scanner;
class GcdLcm {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("G. Greatest common divisor");
System.out.println("L. Lowest common multiple");
System.out.print("Enter G or L, then two numbers: ");
char ch = sc.next().charAt(0);
int a = sc.nextInt(), b = sc.nextInt();
int x = a, y = b;
while (y != 0) { // Euclid: replace (x, y) by (y, x % y)
int r = x % y;
x = y;
y = r;
}
int gcd = x;
switch (ch) {
case 'G':
case 'g':
System.out.println("GCD = " + gcd);
break;
case 'L':
case 'l':
System.out.println("LCM = " + (a * b / gcd));
break;
default:
System.out.println("Wrong letter, enter G or L");
}
}
}
The GCD is worked out once, before the switch, because both options need it. The LCM then comes from the rule a x b = GCD x LCM.
| Variable | Type | Purpose |
|---|---|---|
| ch | char | the letter chosen, G or L in either case |
| a, b | int | the two numbers entered |
| x, y | int | working copies changed by Euclid's loop |
| r | int | remainder of x divided by y |
| gcd | int | greatest common divisor of a and b |
G. Greatest common divisor L. Lowest common multiple Enter G or L, then two numbers: G 84 36 GCD = 12 G. Greatest common divisor L. Lowest common multiple Enter G or L, then two numbers: l 84 36 LCM = 252 G. Greatest common divisor L. Lowest common multiple Enter G or L, then two numbers: x 4 6 Wrong letter, enter G or L
The small l reaches the LCM block through the stacked label. Copies x and y are used in the loop so that a and b are still intact for the LCM.
Many Section B menus pair a nested loop pattern with the sum of a series. Each case is then a complete small program; the switch only chooses between them.
import java.util.Scanner;
class PatSeries {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("1. Symbol pattern");
System.out.println("2. Sum of the series 2/3 + 4/5 + 6/7 + ...");
System.out.print("Enter choice and n: ");
int ch = sc.nextInt();
int n = sc.nextInt();
switch (ch) {
case 1:
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (j % 2 == 1)
System.out.print("* ");
else
System.out.print("# ");
}
System.out.println();
}
break;
case 2:
double s = 0;
for (int k = 1; k <= n; k++)
s = s + (2.0 * k) / (2 * k + 1);
System.out.println("Sum = " + s);
break;
default:
System.out.println("Choose 1 or 2");
}
}
}
Term k is 2k over 2k + 1. Writing 2.0 * k makes the division real; with 2 * k every term would be 0.
1. Symbol pattern 2. Sum of the series 2/3 + 4/5 + 6/7 + ... Enter choice and n: 1 5 * * # * # * * # * # * # * # * 1. Symbol pattern 2. Sum of the series 2/3 + 4/5 + 6/7 + ... Enter choice and n: 2 4 Sum = 3.212698412698413 1. Symbol pattern 2. Sum of the series 2/3 + 4/5 + 6/7 + ... Enter choice and n: 7 3 Choose 1 or 2
Check case 2 by hand for n = 2: 2/3 + 4/5 is about 0.667 + 0.8, which is 1.467. One quick check like this catches a wrong term formula before the examiner does.
The loop rules behind case 1 are set out on pattern programs for ICSE, and case 2 belongs to the family on series programs in Java for ICSE. A menu over three number checks, spy, Niven and neon, is worked on special number programs in Java.
Q3. How do you make a menu repeat until the user exits?
Wrap the menu and the switch in a do-while loop that runs until the exit choice is entered. do-while fits because the menu must appear at least once. Moving each option's work into a method keeps the switch short and shows user-defined methods at the same time.
import java.util.Scanner;
class Wallet {
double balance = 0;
void deposit(double amt) {
balance = balance + amt;
System.out.println("Deposited. Balance = " + balance);
}
void withdraw(double amt) {
if (amt > balance)
System.out.println("Not enough balance");
else {
balance = balance - amt;
System.out.println("Withdrawn. Balance = " + balance);
}
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
Wallet w = new Wallet();
int ch;
do {
System.out.println("1. Deposit 2. Withdraw 3. Balance 4. Exit");
System.out.print("Choice: ");
ch = sc.nextInt();
switch (ch) {
case 1:
System.out.print("Amount: ");
w.deposit(sc.nextDouble());
break;
case 2:
System.out.print("Amount: ");
w.withdraw(sc.nextDouble());
break;
case 3:
System.out.println("Balance = " + w.balance);
break;
case 4:
System.out.println("Thank you");
break;
default:
System.out.println("Invalid choice, try again");
}
} while (ch != 4);
}
}
ch is declared before the do so that the while condition can see it. Declared inside the loop, it would be out of scope and the program would not compile.
| Name | Type | Purpose |
|---|---|---|
| balance | double | instance variable: money held in the wallet |
| amt | double | parameter: amount to add or take out |
| w | Wallet | the object whose methods are called |
| ch | int | menu choice; 4 ends the loop |
| deposit, withdraw | void methods | do the work of options 1 and 2 |
1. Deposit 2. Withdraw 3. Balance 4. Exit Choice: 1 Amount: 500 Deposited. Balance = 500.0 1. Deposit 2. Withdraw 3. Balance 4. Exit Choice: 2 Amount: 800 Not enough balance 1. Deposit 2. Withdraw 3. Balance 4. Exit Choice: 2 Amount: 120 Withdrawn. Balance = 380.0 1. Deposit 2. Withdraw 3. Balance 4. Exit Choice: 5 Invalid choice, try again 1. Deposit 2. Withdraw 3. Balance 4. Exit Choice: 3 Balance = 380.0 1. Deposit 2. Withdraw 3. Balance 4. Exit Choice: 4 Thank you
Choice 5 reaches default and the loop simply offers the menu again. The withdraw method guards against taking out more than the balance.
| If the question says | Write |
|---|---|
| "Write a menu driven program to ..." with no mention of repeating | One menu, one switch, no loop (Programs 1 to 3) |
| "... until the user chooses to exit" or "the menu should be displayed repeatedly" | do-while around the menu and switch, with an exit case (Program 4) |
| "Using a switch case and user-defined methods ..." | Each case calls a method; the method does the work and prints or returns the result |
Methods that return values to a switch, and how to overload them, are covered on user-defined methods and overloading for ICSE Class 10. Bill programs that use a slab ladder instead of a menu are on slab and bill programs for ICSE.
Q4. What do switch case questions in Section A ask?
Short switch questions test four things: what a fragment prints when a break is missing, how to convert an if-else ladder into a switch, which selector types are allowed, and which case labels will not compile. Try each before opening the answer.
Rewrite with switch: marks m (0 to 100) give grade A for 90 and above, B for 70 to 89, C for 60 to 69 and D below 60.
int m = 74;
char g;
switch (m / 10) {
case 10:
case 9: g = 'A'; break;
case 8:
case 7: g = 'B'; break;
case 6: g = 'C'; break;
default: g = 'D';
}
System.out.println(g);
// Output: B
switch cannot test a range, so divide by 10 to turn each band into one value. 100 / 10 is 10, so case 10 is stacked on case 9.
Predict the output.
int x = 3;
switch (x) {
case 3: x += 2;
case 4: x *= 2; break;
case 5: x = 0;
}
System.out.println(x);
// Output: 10
Control enters at case 3 (x becomes 5), has no break, so falls into case 4 (x becomes 10) and stops at that break. The new value of x does not send control to case 5: the case is chosen only once, at the top.
Predict the output. The default label does not have to come last.
int k = 7;
switch (k % 3) {
default: System.out.print("D");
case 0: System.out.print("Z"); break;
case 2: System.out.print("T");
}
// Output: DZ
7 % 3 is 1, which has no case, so control goes to default, prints D, falls into case 0, prints Z and breaks.
Can a switch work on a String? Yes. Since Java 7 the selector can be a String, compared with equals behind the scenes.
String op = "MUL";
switch (op) {
case "ADD": System.out.println(6 + 3); break;
case "MUL": System.out.println(6 * 3); break;
default: System.out.println("?");
}
// Output: 18
| Fragment | javac 21 says | The rule |
|---|---|---|
double d = 2.0; switch (d) { case 2.0: ... } | selector type double is not allowed | With constant case labels, as in every ICSE switch, the selector may be byte, short, char, int, their wrappers, String or an enum; never double, float, long or boolean |
case 1: ... break; case 1: ... | duplicate case label | Each case value may appear only once in a switch |
int k = 1; ... case k: ... | constant expression required | A case label must be a constant or a literal, not a variable |
| switch | if-else ladder |
|---|---|
| Tests one expression for equality with fixed values | Can test any condition, including ranges and several variables |
| Works with int, char, String and similar types only | Works with any type, double and boolean included |
| Needs break to stop fall-through into the next case | Runs only the first true branch; no break needed |
| Natural fit for a menu of numbered or lettered choices | Natural fit for slabs, bands and compound conditions |
More fragments like these, sorted by trap, are on ICSE Computer Applications output questions, and compile errors of every kind are practised on ICSE Class 10 Java error finding questions.
Q5. How are menu programs drilled in the live class?
The five-part template is learnt in the first lesson and then reused in every menu afterwards, so the class time goes on the logic inside each case and on testing.
At the start of the Tuesday 5:30 PM IST class, students write the empty menu skeleton from memory in under two minutes: menu lines, choice, cases, breaks, default.
The teacher sets a two- or three-option question in board wording. Each case is then planned as its own small program, with its own input and output.
At the Wednesday 8:00 PM IST class the programs are run in BlueJ with one input per option and one wrong choice, so a missing default or break shows up on screen.
Hand-written answers are marked against a scheme with the class watching: logic, syntax, the default message, comments and the variable table.
Short fall-through, conversion and error questions return in the weekly Section A set so they stay fresh until the exam.
From December, menu questions appear in full two-hour mock papers alongside the other Section B families.
The full list of Section B program families, with links to each, is on ICSE Class 10 Java programs for practice.
Batch or personalised: you choose
The template, the test-every-path habit and the BlueJ checks are the same in both formats. In India, families choose the fixed evening mini batch or a private slot; ICSE students abroad are taught one to one. Billing is monthly, with no admission fee.
Option 1 · Fixed batch timings
₹2,999
per month, two live classes a week
Option 2 · Choose your own timing
₹4,999
per month, one private class a weektwo private classes a week, at a time set with you
Outside India: the ICSE Computer Applications course runs as personalised one to one, two private classes a week at a time set in your own time zone. The mini batch is taught for families in India.
If your child writes correct logic but keeps losing marks for a missing break or a forgotten default, a few one to one sessions on the template usually settle it. If menus are one of several Section B families still to practise, the twice-weekly batch covers them all in turn. The fee for each format appears in your local currency.
Studying outside India?
ICSE schools overseas write the same Computer Applications paper, so the same switch menus and the same default case decide marks there too. Outside India the lessons are one to one, at an early evening time in the student's own zone.
| Where you live | Time difference | Usual class window, local time | Format |
|---|---|---|---|
| India (IST) every Indian city | IST | Tue 5:30 PM, Wed 8:00 PM | Mini batch or 1-on-1 |
| United Arab Emirates Dubai, Sharjah | 1 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Indonesia and Thailand West Java, Bangkok area | 1 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
| Singapore Singapore | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
The time is agreed after the free demo and can be moved around school exams. How the overseas lessons are arranged is explained on ICSE Computer Applications classes in the Gulf and abroad.
What families say
Real reviews from real families. We neither write nor commission them.
★★★★★
"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."
Ria Mukherjee
Parent
★★★★★
"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."
Samriddha Mondal
Student
★★★★★
"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."
Vansh Agarwal
Student
★★★★★
"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."
Sonam Oswal
Parent of Dhairya
★★★★★
"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."
Sonu Goyal
Parent
★★★★★
"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."
Ritu Kedia
Parent
The rest of the Class 10 series
Every page in the ICSE Class 10 Computer Applications series, grouped by what you need: classes, each chapter, Section B programs, question practice, notes and revision, and the exam itself.
CBSE Class 10 AI (417): The Mon and Wed 9 PM AI batch CBSE AI 417 syllabus explained CBSE AI important questions Sample paper and mock tests
Questions about menu programs
It is a program that shows the user a list of options, reads which option they want, and then runs only the code for that option. In ICSE Class 10 the choice is read with Scanner and the branching is done with a switch statement, with a default case for a choice that is not on the list.
Print the menu with one println per option, read the choice into an int or char, then write switch (choice) with one case per option. Put the full logic for each option inside its case and end it with break. Finish with a default case that prints a message such as "Invalid choice".
ICSE questions usually ask for an appropriate message when the user enters a wrong choice, and the default case is where that message goes. Leaving it out means a wrong choice silently does nothing, and the answer misses part of what the question asked.
Control falls through into the next case and runs its statements too, until it meets a break or the end of the switch. The case is chosen only once, at the top, so changing the variable inside a case does not redirect control. Stacking labels such as case 'A': case 'a': uses fall-through on purpose.
Yes. Read the choice with sc.next().charAt(0) and write each label in single quotes, such as case 'G':. To accept both capital and small letters, stack two labels on the same block of code.
No. In the switch with constant case labels that ICSE uses, the selector may be byte, short, char, int, their wrapper classes, a String or an enum. A double, float, long or boolean selector does not compile, so use an if-else ladder for those.
switch compares one expression with fixed constant values and needs break to stop fall-through. if-else can test any condition, including ranges and several variables, and runs only the first true branch. Menus suit switch; slabs and ranges suit if-else.
Put the menu and the switch inside a do-while loop and declare the choice variable before the loop. Add an exit option, for example case 4, and end the loop with while (choice != 4). do-while suits a menu because it must be shown at least once.
Menu and switch case questions are a regular Section B shape, often pairing a pattern with a series or two calculations. Switch also appears in Section A as output and conversion questions. Practising the five-part template prepares a student for both.
Yes. In the ICSE mini batch students write menus to the five-part template by hand, then run every option and one wrong choice in BlueJ on a shared screen. Students who need more time can take personalised one to one classes at a time the family chooses.
Start
In the free demo your child writes the menu skeleton with the mentor, fills in two options from a board-style question, and runs every choice in BlueJ, a wrong one included. Afterwards you hear plainly what is secure and what needs work, and whether the mini batch or one to one fits better.
Prefer to see the whole subject first? Visit ICSE Computer Applications important questions or the ICSE Class 10 Java classes.
WhatsApp us · +91 91233 66161 · connect@modernagecoders.com
Every class is live video. The form requests a callback and reserves nothing.
A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.
Book a priority demo