Java Mid Term-4
Attempt All
Question 1:
Write a program to input a sentence and print the number of characters found in the longest
word of the given sentence.
For example is S = “India is my country” then the output should be 7. [15]
Question 2:
Write a menu driven program to accept a number and check and display whether it is a Prime
Number or not OR an Automorphic Number or not. (Use switch-case statement). [15]
(a) Prime number : A number is said to be a prime number if it is divisible only by 1 and itself
and not by any other number. Example : 3,5,7,11,13 etc.
(b) Automorphic number : An automorphic number is the number which is contained in the last
digit(s) of its square.
Example: 25 is an automorphic number as its square is 625 and 25 is present as the last two
digits.
Question 3
Write a program to input a string in uppercase and print the frequency of each character. [15]
1 INPUT : COMPUTER HARDWARE
2 OUTPUT :
3 CHARACTERS FREQUENCY
4A 2
5C 1
6D 1
So on
Question 4
Write a menu driven program to perform the following . (Use switch-case statement) [15]
(a) To print the series 0, 3, 8, 15, 24 ……. n terms (value of ‘n’ is to be an input by the user).
(b) To find the sum of the series given below:
S = 1/2+ 3/4 + 5/6 + 7/8 … 19/20
Question:5
Write a program accept any number and print that in words: [ 264 : Two Six Four ].
Debasish Das