# Class As a User Defined Data Type

#### Java : **Class As a User Defined Data Type** Program List

**Program [1]**

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.

A number is said to be prime if it has only two factors I and itself.

**Write a program to accept one no check the number where it is Circular Prime or Not.**

**Example 1**

INPUT :N = 197

OUTPUT: 197 971 719 197 IS A CIRCULAR PRIME

**Example 2**

INPUT :N = 1193

OUTPUT: 1193 1931 9311 3119 1193 IS A CIRCULAR PRIME

**Example 3**

INPUT :N = 29

OUTPUT: 29 92 29 IS NOT A CIRCULAR PRIME

**Program [2]**

Write a Program in Java to input a number and check whether it is a Bouncy Number or not.

**Increasing Number **: Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 22344.

**Decreasing Number** : Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 774410.

**Bouncy Number **: We shall call a positive integer that is neither increasing nor decreasing a “bouncy” number; for example, 155349. Clearly there cannot be any bouncy numbers below 100.

**Sample:**

Enter a number : 22344

The number 22344 is Increasing and Not Bouncy

Enter a number : 774410

The number 774410 is Decreasing and Not Bouncy

Enter a number : 155349

The number 155349 is bouncy

**Program [3]**

Design a program to accept a fifteen digit number from the user and check whether it is a valid IMEI number or not. For an invalid input, display an appropriate message.

The **International Mobile Station Equipment Identity** or IMEI is a number, usually unique, to identify mobile phones, as well as some satellite phones. It is usually found printed inside the battery compartment of the phone.

The IMEI number is used by a GSM network to identify valid devices and therefore can be used for stopping a stolen phone from accessing that network.

The IMEI (15 decimal digits: 14 digits plus a check digit) includes information on the origin, model, and serial number of the device.

The IMEI is validated in three steps:

1. Starting from the right, double every other digit (e.g., 7 becomes 14).

2. Sum the digits (e.g., 14 → 1 + 4).

3. Check if the sum is divisible by 10.

**Sample output**

1. Enter a 15 digit IMEI code : 654122487458946 Output : Sum = 80 Valid IMEI Code

2. Enter a 15 digit IMEI code : 799273987135461 Output : Sum = 79 Invalid IMEI Code

3. Enter a 15 digit IMEI code : 79927398713 Output : Invalid Input

**Program [4]**

The result of a quiz competition is to be prepared as follows:

The quiz has five questions with four multiple choices (A, B, C, D), with each question carrying 1 mark for the correct answer. Design a program to accept the number of participants N such that N must be greater than 3 and less than 11. Create a double dimensional array of size (Nx5) to store the answers of each participant row-wise.

Calculate the marks for each participant by matching the correct answer stored in a single dimensional array of size 5. Display the scores for each participant and also the participant(s) having the highest score.

Example: If the value of N = 4, then the array would be:

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

Example 1

INPUT : N = 5

Participant 1 D A B C C

Participant 2 A A D C B

Participant 3 B A C D B

Participant 4 D A D C B

Participant 5 B C A D D

Key: B C D A A

OUTPUT : Scores :

Participant 1 D A B C C

Participant 1 = 0

Participant 2 = 1

Participant 3 = 1

Participant 4 = 1

Participant 5 = 2

Highest score: Participant 5

Example 2

INPUT : N = 4

Participant 1 A C C B D

Participant 2 B C A A C

Participant 3 B C B A A

Participant 4 C C D D B

Key: A C D B B

OUTPUT : Scores :

Participant 1 = 3

Participant 2 = 1

Participant 3 = 1

Participant 4 = 3

Highest score:

Participant 1

Participant 4

Example 3

INPUT : N = 12

OUTPUT : INPUT SIZE OUT OF RANGE.