Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views1 page

Java Mid Term 4

The document contains a Java mid-term exam with five programming questions. The questions require students to write programs for various tasks, including counting characters in the longest word, checking for prime and automorphic numbers, character frequency in a string, generating a specific series, and converting numbers to words. Each question is designed to assess different programming skills and concepts in Java.

Uploaded by

ishmitsinghania
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)
8 views1 page

Java Mid Term 4

The document contains a Java mid-term exam with five programming questions. The questions require students to write programs for various tasks, including counting characters in the longest word, checking for prime and automorphic numbers, character frequency in a string, generating a specific series, and converting numbers to words. Each question is designed to assess different programming skills and concepts in Java.

Uploaded by

ishmitsinghania
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/ 1

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

You might also like