Computer Science, asked by bhan61, 1 year ago

Write a method that takes as paramater an integer. This integer is a 2 digit number.

Depending on the value of the number, print the English word for this number.

Only write the method - assume that the Class & main method have been defined.

Use the System.out.println() statement for printing.

Example Input: 45
Output: forty-five
Example Input: 13
Output: thirteen
Example Input: 87
Output: eighty-seven


bhan61: can anyone please tell me the code by using switch case ,i need very urgent.

Answers

Answered by nitish8089
4

import java.util.Scanner;

class Number{

public static void met(int number){

String[] ones={" ","one","two","three","four","five","six","seven","eight","nine","ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};

String [] tens={" ","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninety"};

if(number>19){

System.out.println(tens[(number/10)-1]+" "+ones[number%10]);

}

else{

System.out.println(ones[number]);

}

}

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

System.out.println("Enter any two digit numbers:");

int number=sc.nextInt();

Number.met(number);

}

}

Answered by goutamipurra
2

Answer:

class Solution {

 public static void Met(int n){

   switch(n){

      case 10:

       System.out.println("ten");

      break;

       case 11:

       System.out.println("eleven");

      break;

       case 12:

       System.out.println("twelve");

        break;

       case 13:

      System.out.println("thirteen");

       break;

       case 14:

        System.out.println("fourteen");

       break;

       default:

           System.out.println();

           break;

   }  

 }

Explanation:

Similar questions