java

write a short program to input a digit and print it in words in java

write a short program to input a digit and print it in words in java

java

write a short program to input a digit and print it in words in java

 

package com.company;

import java.util.Scanner;

public class StringProg2
{
    static void printValue(int 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;

            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;
        }
    }

    static void printWord(String N)
    {
        int i, length = N.length();
        for (i = 0; i < length; i++)
        {
            printValue(N.charAt(i));
        }
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("Input String : ");
        String str = sc.nextLine();
        printWord(str);
    }
}

 


 

 


 

Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

πŸ§‘β€πŸ’»πŸ§‘β€πŸ’»Β Social MediaΒ LinksΒ ofΒ Tech DCodeΒ :

πŸ‘‰πŸ» YouTube :Β https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
πŸ‘‰πŸ» Instagram :Β https://www.instagram.com/thetechdcode/
πŸ‘‰πŸ» Facebook Page :Β https://www.facebook.com/thetechdcode
πŸ‘‰πŸ» Twitter :Β https://twitter.com/thetechdcode
πŸ‘‰πŸ» Telegram Channel :Β https://t.me/thetechdcode
πŸ‘‰πŸ» Tech DCode Linktree :Β https://linktr.ee/thetechdcode
πŸ‘‰πŸ» My Personal Handles :Β https://linktr.ee/virtualshivamin

πŸ§‘β€πŸ’»πŸ§‘β€πŸ’»Β Social Media LinksΒ ofΒ SHIVAM SINGHΒ (OWNER) :

πŸ‘‰πŸ» Instagram :Β https://www.instagram.com/virtualshivamin/
πŸ‘‰πŸ» Facebook Page :Β https://www.facebook.com/virtualshivamin/
πŸ‘‰πŸ» Twitter :Β https://twitter.com/virtualshivamin/
πŸ‘‰πŸ» Personal Linktree :Β https://linktr.ee/virtualshivaminΒ 


	

Leave a Reply

Your email address will not be published. Required fields are marked *