0% found this document useful (0 votes)
12 views8 pages

Computer Project Term 2 XI

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

Computer Project Term 2 XI

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

[UNIQUENUMBER]

Write a program in Java to input a number from the user


and then check whether the number is a Unique Number
or not.
Unique Number is a positive integer without leading to
zeroes with no duplicate digits. For example, 7, 135, 214,
5243 are all unique numbers. Whereas 33, 3121, 200 are
not unique numbers.

Ex:

INPUT: Enter a number


16845

OUTPUT: 16845 is a Unique Number

INPUT: Enter a number


75120

OUTPUT: 75120 is not a Unique Number


-
[NUM TOWO RDS]
• Write a program in Java to input a natural number less
than 1000 and display the number in words.

Ex:

INPUT: Enter a number


526

OUTPUT: Five Hundred And Twenty Six

INPUT: Enter a number


69

OUTPUT: Sixty Nine


[PER MUT ATIO N]
Write a program in Java to input a word and then show all
the possible permutations of that word.

Ex:

INPUT: Enter a word


dog
~
~ OUTPUT: All permutations:
~
dog
i)
dgo
~
odg
J
ogd
)
god
J
gdo
'
)
INPUT: Enter a word
cat

OUTPUT: All permutations:


cat
eta
act
ate
tac
tea
[HAR SHAD NUMB ER]
Write a program in Java to input a number from the user
and then check whether the number is an
HarshadNumber or not.
Harshad numbers are those integers which· are divisible
by the sum of the digits of the number.
For example, the numbe r 198.
Sum of the digits of the number, 198 => 1 + 9 + 8 = 18,
and, 18 * 11 = 198.
Hence, the numbe r 198 is a Harshad number .

Ex:

INPUT: Enter a numbe r


198

OUTPUT: The numbe r is a Harshad Numbe r

INPUT: Enter a numbe r


7512

OUTPUT: The numbe r is not a Harsha d Numbe r


[CIRCU LAR PRIME]
Write a program to find whether a number is Circular Prime
Number or not.

A circular prime is a prime number that remains prime under


cyclic shifts of its digits. When the leftmost digit is removed and
replaced at the end of the remaining string of digits, the
generated number is still prime. The process is repeated until
the original number is reached again.

Ex: 131, 197, 1193 etc.

Input: 131

Output: The number is Circular Prime

Input: 123

Output: The number is not Circular Prime

Input: 1193

n umber is Circular Prime


Output: Th e
[SADDLE POINT]
Write a program in java to find the value of saddle point of a
given array and also give proper output when saddle point is
not present.

Ex:

Input: Enter row of array


2
Enter array elements
1
2
3
4
Output: Value of saddle point 3

Input: Enter row of array


2 .
Enter array elements
9
5
6
8
Output: No saddle point
The words may be separated by a single blank space and should be case-insensitive.
Perform the following tasks:
(a) Determine if the accepted sentence is a Pangram or not.
( A Pangram is a sentence that contains every letter of the alphabet at least once.)
Example: ''The quick brown fox jumps over the lazy dog"
(b) Display the first occurring longest and shortest word in the accepted sentence.

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

Example 1
INPUT: Pack my box with five dozen liquor jugs.

OUTPUT: IT IS A PANGRAM
LONGEST WORD: dozen
SHORTEST WORD: my

Example 2
INPUT: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
OUTPUT: IT IS A PANGRAM
LONGEST WORD: QUICK
SHORTEST WORD: THE

Example3
INPUT: Hello my World.
OUTPUT: IT IS NOT A PANGRAM
LONGEST WORD: Hello
SHORTEST WORD: my

Example4
INPUT: Alas ! it failed #
OUTPUT: INVALID INPUT
of rows and the number of columns, such that M must be greater than 2 and less than I0.
Accept the value of M as user input. Display an appropriate message for an invalid input.
Allow the user to input integers into this matrix. Perfonn the following tasks:
(a) Display the original matrix.
(b) Check if the given matrix is Symmetric or not.
A square matrix is said to be Symmetric, if the element of the i'11 row and j 111 column
is equal to the element of the j'h row and i111 column.
(c) Find the sum of the elements of left diagonal and the sum of the elements of right
diagonal of the matrix and display them.
Test your program for the following data and some random data:

Example I
INPUT: M=3
Enter elements of the matrix:
I 2 3
2 4 5
3 5 6
OUTPUT: ORIGINAL MATRIX
I 2 3
2 4 5
3 5 6
THE GIVEN MATRIX IS SYMMETRIC
The sum of the left diagonal = 11
The sum of the right diagonal = I0

Example 2
INPUT: M=4
Enter elements of the matrix:
7 8 9 2
4 5 6 3
8 5 3 I
7 6 4 2
OUTPUT: ORIGINAL MATRIX
7 8 9 2
4 5 6 3
8 5 3 I
7 6 4 2
THE GIVEN MA TRIX IS NOT SYMMETRIC
The sum of the left diagonal = 17
The sum of the right diagonal = 20

ExampleJ
INPUT: M= 12
OUTPUT: SIZE IS OUT OF RANGE

You might also like