Computer Science, asked by bhan61, 1 year ago

A method specialPrint has been defined. It takes as input an integer and prints each of the digits in word format.

Example: for input specialPrint(62), it prints: six two

Write a program that uses specialPrintto print the values for 37, 93, 14 and 568.

Write only the main method. The Mainclass has already been defined


bhan61: can anyone please send me answer
bhan61: please give me reply

Answers

Answered by nitish8089
0

public static void specialPrint(int n){

         String str=""+n;

         for(int i=0;i<str.length();i++){

      switch(str.charAt(i)){

   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;

   case '5':

   System.out.print("five ");

   break;

   case '6':

   System.out.print("six ");

   break;

   case '7':

   System.out.print("seven ");

   break;

   case '8':

   System.out.print("eight ");

   break;

   case '9':

   System.out.print("nine ");

   break;

   default:

   System.out.print("Invalid Input");

   System.exit(0);

  }

 }

}

Similar questions