InterviewSolution
Saved Bookmarks
| 1. |
WAP that accepts numbers and displays whether the number is odd or even. Accept numbers till the uses enter zero. |
|
Answer» import java.io.*; class no { public void check ( ) throws IO Exception { BufferedReader br=new BufferedReader (new InputStreamReader(System.in)); int num; String str; System.out.printIn(“Enter zero to quit”); do { str=br.readLine ( ); num=Integer.parseInt (str); if (num %2==0) System.out.printIn(“odd”); } while (num !=0); } } |
|