How to print the given numbers in character using Nested If Statement in Java.


The Below Post Will Explain You how to print the given numbers in character using Nested If Statements in Java.

The Below Post Will Explain You how to print the given numbers in character using Nested If Statements in Java.

importjava.io.DataInputStream;
publicclass innestedif {
       /**
        * @param Gopi TechMarket
        */
       publicstaticvoid main(String[] args) {
              // TODO Auto-generated method stub
              try
              {
              int number;
              System.out.println(“Enter Student a Number:”);
              DataInputStream ds = newDataInputStream(System.in);
              number = Integer.parseInt(ds.readLine());
              if(number == 1 )
              {
                     System.out.println(“ONE”);
              }
              elseif(number == 2)
              {
                     System.out.println(“TWO”);
              }
              else
              {
                     System.out.println(“Enter Number Only beween one and nine”);
              }
              }
              catch(Exception ex)
              {}
       }
}
 
 
Output:
 
Enter Student a Number: 2
 
TWO
 
This post has shown only two numbers if you want you can also add as many as you need.
Hope this will help you.
Advertisements

One thought on “How to print the given numbers in character using Nested If Statement in Java.

Tell us Your Suggestion

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s