Page 164 - CA_Blue( J )_Class9
P. 164

if(n3>=15)
                             System.out.println(n3 + "is greater than or equal to 15");


                   Program 4      Write a program to input a number from 1 and 5 and print the number in alphabets.

                     1     import java.util.*;
                     2     class num_letter

                     3     {
                     4     public static void main()

                     5         {
                     6             Scanner sc= new Scanner(System.in);

                     7             int n;
                     8             System.out.print("Enter a number from 1 to 5 : ");

                     9             n = sc.nextInt();
                    10             System.out.println("----------------------------");

                    11             System.out.println("Digit : "+ n);
                    12             if(n==1)

                    13                   System.out.println("IN ALPHABET : ONE");
                    14             if(n==2)

                    15                   System.out.println("IN ALPHABET : TWO");
                    16             if(n==3)

                    17                   System.out.println("IN ALPHABET : THREE");
                    18             if(n==4)

                    19                   System.out.println("IN ALPHABET : FOUR");
                    20             if(n==5)

                    21                   System.out.println("IN ALPHABET : FIVE");
                    22             System.out.println("----------------------------");
                    23         }

                    24     }

                  You will get the following output:

















                   162    Touchpad Computer Applications-IX
   159   160   161   162   163   164   165   166   167   168   169