write a program to print the name of the entered natural no 1 to 10 - Code

Latest

programs

Monday, March 2, 2015

write a program to print the name of the entered natural no 1 to 10



ALGORITHM:

Step 1: Start

Step 2: Read the value

Step 3: Switch case and print the name of the number Step 4: Print the desired output
Step 5: Stop

PROGRAM: import java.io.*; class natno

{

public static void main(String args[])throws IOException

{

BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); int a;
System.out.println("Enter the value"); a=Integer.parseInt(br.readLine()); switch(a)

{ case 1 : System.out.println("One"); break ;

case 2 : System.out.println("Two"); break ;
case 3 : System.out.println("Three"); break ;
case 4 : System.out.println("Four"); break ;
case 5 : System.out.println("Five"); break ;
case 6 : System.out.println("Six"); break ;
case 7 : System.out.println("Seven"); break ;
case 8: System.out.println("Eight"); break ;
case 9 : System.out.println("Nine"); break ;
case 10 : System.out.println("Ten"); break ;



13


default : System.out.println("Invalid choice"); break ;
}

}

}

OUTPUT:

D:\JAVA>javac natno.java D:\JAVA>java natno Enter the value

7 Seven
D:\JAVA>

No comments:

Post a Comment