You are on page 1of 3

Java

1. Design a java program which inputs a date in six digit number format i.e 141296. Test the validity of the date and print the date in full form. If date is invalid then print a msg as Invalid Date

Example: INPUT : 141296 OUTPUT : 14th December 96 :VALID DATE INPUT : 300284 OUTPUT :INVALID DATE
2. Write a Java program to fill in a two dimensional array in a circular fashion with natural numbers from 1 to N2, given N as input. Example: If N=4,N2=16, then the array will be 1 2 3 4 12 11 10 13 16 9 14 15 8 5 6 7

3. Accept a paragraph of text consisting of sentences that are terminates by either ., ,, !, or a ? followed by a space. Assume that there can be a maximum of 05 sentences in a paragraph. Design a Java program to perform the following: (a)Arrange the sentences in alphabetical order of words,sentence by sentence. (b) Separate the words which begin with a vowel. Sample Data 1: INPUT : HELLO ! HOW ARE YOU ? WHEN ARE YOU COMING ? HOPE TO SEE YOU SOON. OUTPUT : HELLO ! ARE HOW YOU ? ARE COMING WHEN YOU ? HOPE SEE SOON TO YOU.

4. Write a Java program to encode a string using given set of rules.E.g. Write a program that will replace every character in a string with a character which is found next to that character in your keyboard (with few assumptions and other rules).[E.g. replace q with w, t with y] with an assumption shift is off and caps lock is off.

5. Write a java program that simulates a traffic light. The program lets the user select one of the three lights : red, yellow or green. When a radio button is selected , the light is turned on, and only one light can be on at a time. No light should be on ,when the program starts.

6 . Create a java program that repeatedly queries the user to enter positive integers. As each positive integer is entered.it is saved,until the user enters a zero .Then all of the positive integers are displayed on the screen as , one per line , in reverse order of the order they were entered. If the user enters a string that is not a valid integer, the program queries the user till a valid integer is entered. You an assume that no negative integers will be entered.

Example: Please enter a positive Integer> 50

Please enter a positive integer> Fred Please enter a positive integer> Barney Please enter a positive integer> 40 Please enter a positive integer> 30 Please enter a positive integer> 0

Output: 30 40 50

You might also like