Skip to content

Commit 352a057

Browse files
committed
feat: Add menu-based language selection with switch-case and exit option
🧠 Logic: - Displays a menu in a loop using `do-while` - Takes user input to choose a language - Uses `switch` to print corresponding message - Exits loop when user selects option 4. Signed-off-by: Somesh diwan <[email protected]>
1 parent a6959c2 commit 352a057

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Section7ConditionalStatements/Practice/src/case22.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
import java.util.Scanner;
22

3-
class Case22
4-
{
5-
public static void main(String[] args)
6-
{
3+
class Case22 {
4+
public static void main(String[] args) {
75
int ch;
8-
do
9-
{
6+
do {
107
System.out.println("1.Marathi 2.Hindi 3.English 4.Exit");
118
Scanner sc = new Scanner(System.in);
129
ch = sc.nextInt();
13-
switch(ch)
14-
{
10+
11+
switch(ch) {
1512
case 1: System.out.println("You have selected Marathi");
1613
break;
17-
1814
case 2: System.out.println("You have selected Hindi");
1915
break;
20-
2116
case 3: System.out.println("You have selected English");
2217
break;
23-
2418
case 4: System.out.println("Exited the menu");
2519
break;
26-
2720
default: System.out.println("You have selected the wrong option");
2821
}
2922
}

0 commit comments

Comments
 (0)