Java program for accepting a number and printing it in words.
eg. input: 1546
output: ONE FIVE FOUR SIX
Answers
Answer:
hii
Explanation:
Mark brain list answer please
Answer:
class GFG
{
static void printValue(char digit)
{
switch (digit)
{
case '0':
System.out.print("Zero ");
break;
case '1':
System.out.print("One ");
break;
case '2':
System.out.print("Two ");
break;
case '3':
System.out.print("Three ");
break;
case '4':
System.out.print("Four ");
break;
// For digit 5
case '5':
System.out.print("Five ");
break;
// For digit 6
case '6':
System.out.print("Six ");
break;
// For digit 7
case '7':
System.out.print("Seven ");
break;
// For digit 8
case '8':
System.out.print("Eight ");
break;
case '9':
System.out.print("Nine ");
break;
}
}
static void printWord(String N)
{
int i, length = N.length();
// Finding each digit of the number
for (i = 0; i < length; i++)
{
// Print the digit in words
printValue(N.charAt(i));
}
}
public static void main(String[] args)
{
String N = "123";
printWord(N);
}
}