Computer Science, asked by shyamdixit280, 11 months ago

Write a program to enter a single digit number (from 0-9) and print it in words by using switch-

case construct, print an appropriate error message for digit greater than 9 or smaller than 0.

Hint: Input: Digit=8

Output: Digit in Words=Eight​

Answers

Answered by AnindaBasu
21

import java.util.*;

class digit

{

public static void main(String args[ ] )

{

Scanner sc=new Scanner(System.in);

int ch;

System.out.println("Enter the choice of digit :- ");

ch=sc.nextInt();

switch (ch)

{

case 0: System.out.println("Zero");

break;

case 1: System.out.println("One");

break;

case 2: System.out.println("Two");

break;

case 3: System.out.println("Three");

break;

case 4: System.out.println("Four");

break;

case 5: System.out.println("Five");

break;

case 6: System.out.println("Six");

break;

case 7: System.out.println("Seven");

break;

case 8: System.out.println("Eight");

break;

case 9: System.out.println("Nine");

break;

default : System.out.println("You entered wrong input ");

break;

}

}

}

Similar questions