Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • IoT ? Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

Java program to print characters of integers

YASH PAL, 31 July 2024

In this tutorial, we are going to write a Java program to print characters of integers in Java Programming with practical program code and step-by-step full complete explanation.

Java program to print characters of integers

Java program to print characters of integers.

 
class SwitchCaseDemo
{
    public static void main(String args[])
    {
        try
        {
            int num = Integer.parseInt(args[0]);
            int n = num; //used at last time check
            int reverse=0,remainder;
        
            while(num > 0)
            {
                remainder = num % 10;
                reverse = reverse * 10 + remainder;
                num = num / 10;
            }

            String result=""; //contains the actual output

            while(reverse > 0)
            {
                remainder = reverse % 10;
                reverse = reverse / 10;
                
                switch(remainder)
                {
 
                    case 0 :
                        result = result + "Zero ";
                        break;
                    
                    case 1 :
                        result = result + "One ";
                        break;
                    
                    case 2 :
                        result = result + "Two ";
                        break;
                
                    case 3 :
                        result = result + "Three ";
                        break;
 
                    case 4 :
                        result = result + "Four ";
                        break;
                    
                    case 5 :
                        result = result + "Five ";
                        break;
 
                    case 6 :
                        result = result + "Six ";
                        break;
                    
                    case 7 :
                        result = result + "Seven ";
                        break;
 
                    case 8 :
                        result = result + "Eight ";
                        break;
                    
                    case 9 :
                        result = result + "Nine ";
                        break;
                
                    default:
                        result="";
                }
            }

            System.out.println(result);
        }
        catch(Exception e)
        {
            System.out.println("Invalid Number Format");
        }
    }
}

Output

 
124
One Two Four
coding problems solutions Java Programming Tutorials

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes