 The total time to be spent on the Planning session and Examination session is Three hours. Planning session: 90 minutes Examination session: 90 minutes Note: Candidates are to be permitted to proceed to the Examination Session only after the 90 minutes of the Planning Session are over.

——————————————————————————————————————–This paper consists of three problems from which candidates are required to attempt any one problem. Candidates are expected to do the following:

1. Write an algorithm for the selected problem. (Algorithm should be expressed clearly using any standard scheme such as pseudo code or in steps which are simple enough to be obviously computable)     

2. Write a program in JAVA language. The program should follow the algorithm and should be logically and syntactically correct. Document the program using mnemonic names / comments, identifying and clearly describing the choice of data types and meaning of variables.          

3. Code / Type the program on the computer and get a print out (Hard Copy). Typically, this should be a program that compiles and runs correctly.    

4. Test run the program on the computer using the given sample data and get a print out of the output in the format specified in the problem.       

——————————————————————————————————————-

In addition to the above, the practical file of the candidate containing the practical work related to programming assignments done during the year is to be evaluated as follows:

• Programming assignments done throughout the year (by the Teacher) 

• Programming assignments done throughout the year (by the Visiting Examiner)          

_______________________________________________________________________

Question 1

A unique-digit integer is a positive integer (without leading zeros) with no duplicate digits. For example 7, 135, 214 are all unique-digit integers whereas 33, 3121, 300 are not.

Given two positive integers m and n, write a program to determine how many unique-digit integers are there in the range between m and n (both inclusive) and output them.

The input contains two positive integers m and n. Assume m < 30000 and n < 30000. You are to output the number of unique-digit integers in the specified range along with their values in the format specified below:

SAMPLE DATA:

INPUT:

m = 100

n  = 120

OUTPUT:

THE UNIQUE-DIGIT INTEGERS ARE:-

102, 103, 104, 105, 106, 107, 108, 109, 120.

FREQUENCY OF UNIQUE-DIGIT IN INTEGERS IS : 9.

INPUT:

m = 2500

n = 2550

OUTPUT:

THE UNIQUE-DIGIT INTEGERS ARE:-

2501, 2503, 2504, 2506, 2507, 2508, 2509, 2510, 2513, 2514, 2516, 2517, 2518, 2519, 2530,     2531, 2534, 2536, 2537, 2538, 2539, 2540, 2541, 2543, 2546, 2547, 2548, 2549.

FREQUENCY OF UNIQUE-DIGIT INTEGERS IS : 28

Question 2

Write a program to accept a sentence which may be terminated by either’.’, ‘?’or’!’ only. The words may be separated by more than one blank space and are in UPPER CASE.

(a) Find the number of words beginning and ending with a vowel.

(b) Place the words which begin and end with a vowel at the beginning, followed by the remaining words as they occur in the sentence.

Test your program with the sample data and some random data:

Example 1

INPUT: ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE.

OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 3

ANAMIKA ARE ANYMORE AND SUSAN NEVER GOING TO QUARREL

Example 2

INPUT: YOU MUST AIM TO BE A BETTER PERSON TOMORROW THAN YOU ARE TODAY.

OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 2

A ARE YOU MUST AIM TO BE BETTER PERSON TOMORROW THAN YOU TODAY

Example 3

INPUT: LOOK BEFORE YOU LEAP.

OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 0

LOOK BEFORE YOU LEAP

Example 4

INPUT: HOW ARE YOU@

OUTPUT: INVALID INPUT

Question 3.

A wondrous square is an n by n grid which fulfills the following conditions:

(i)  It contains integers from 1 to n2, where each integer appears only once.

(ii) The sum of integers in any row or column must add up to 0.5 x n x (n2 + 1).

For example the following grid is a wondrous square where the sum of each row or column is 65 when n = 5:

17        24        1          8          15

23        5          7          14        16

4          6          13        20        22

10        12        19        21        3

11        18        25        2          9

Write a program to read n (2 < n < 10) and the values stored in these n by n cells and output if the grid represents a wondrous square or not.

Also output all the prime numbers in the grid along with their row index and column index as shown in the output. A natural number is said to be prime if it has exactly two divisors. E.g. 2,3,5,7,11 ………..

The first element of the given grid i.e 17 is stored at row index 0 and column index 0 and the next element in the row i.e. 24 is stored at row index 0 and column index 1.

Test your program for the following data and some random data.

SAMPLE DATA:

INPUT:

N = 4

16        15        1          2

6          4          10        14

9          8          12        5

3          7          11        13

OUTPUT:

YES IT REPRESENTS A WONDROUS SQUARE.

PRIME                        ROW INDEX             COLUMN INDEX

2                                              0                                  3

3                                              3                                  0

5                                              2                                  3

7                                              3                                  1

11                                            3                                  2

13                                            3                                  3

15                                            0                                  1

INPUT:

N = 3

1          2          4

3          7          5

8          9          6

OUTPUT:

NOT A WONDROUS SQUARE.

PRIME                        ROW INDEX             COLUMN INDEX

2                                              0                                  1

3                                              1                                  0

5                                              1                                  2

7                                              1                                  1

INPUT:

N = 2

2          3

3          2

OUTPUT:

NOT A WONDROUS SQUARE.

PRIME                        ROW INDEX             COLUMN INDEX

2                                              0                                  0

2                                              1                                  1

SHARE
Previous articlePatterns part 4(Strings)
Next articleEvil number