You are on page 1of 7

TRAINING PROGRAM - 2

LEVEL - 0

MAHESH PATEL
MANTRA SOFTECH INDIA PVT LTD | AHMEDABAD
TABLE OF CONTENTS

1. PENTAGONAL NUMBERS ...................................................................................................................... 2


1.1 Detail ............................................................................................................................................. 2
1.2 Documentation ............................................................................................................................. 2
2. PRIME NUMBERS .................................................................................................................................. 3
2.1 Detail ............................................................................................................................................. 3
2.2 Documentation ............................................................................................................................. 3
3. VALIDATION .......................................................................................................................................... 4
3.1 Detail ............................................................................................................................................. 4
3.2 Documentation ............................................................................................................................. 4
4. SHAPES .................................................................................................................................................. 5
4.1 Detail ............................................................................................................................................. 5
4.2 Documentation ............................................................................................................................. 5
5. RANDOMIZATION.................................................................................................................................. 6
5.1 Detail ............................................................................................................................................. 6
5.2 Documentation ............................................................................................................................. 6
1. PENTAGONAL NUMBERS
Write a Java method to display the first 50 pentagonal numbers.

1.1 Detail
A pentagonal number is a figurate number that extends the concept of triangular and square numbers to
the pentagon, but, unlike the first two, the patterns involved in the construction of pentagonal numbers
are not rotationally symmetrical. See the below image.

Expected Output:

1 5 12 22 35 51 70 92 117 145

176 210 247 287 330 376 425 477 532 590

651 715 782 852 925 1001 1080 1162 1247 1335

1426 1520 1617 1717 1820 1926 2035 2147 2262 2380

2501 2625 2752 2882 3015 3151 3290 3432 3577 3725

1.2 Documentation
Write a paper on program with description or detail understanding of logic.
2. PRIME NUMBERS
Write a Java method to display the first 50 pentagonal numbers.

2.1 Detail
A prime number is the number that is divisible only by itself.

Expected Output:

(3, 5)

(5, 7)

(11, 13)

(17, 19)

(29, 31)

(41, 43)

(59, 61)

(71, 73)

2.2 Documentation
Write a paper on program with description or detail understanding of logic.
3. VALIDATION
Write a Java method to check whether a string is a valid password.

3.1 Detail
Strong password is the most important factor for any account for security reasons. Strong password
provides more security to the account. Below are the rules to be followed with the password.

Below are the rules:

A password must have at least ten characters.


A password must include at least one capital letter.
A password must include at least one small letter.
A password must include at least one digit.
A password must include at least one special character.

Expected Output:

1. A password must have at least ten characters.


2. A password must include at least one capital letter.
3. A password must include at least one small letter.
4. A password must include at least one digit.
5. A password must include at least one special character.

Input a password (You are agreeing to the above Terms and Conditions.): Mantra@123
Password is valid.

Input a password (You are agreeing to the above Terms and Conditions.): mantra@123
Password is invalid (check rule 2).

3.2 Documentation
Write a paper on program with description or detail understanding of logic.
4. SHAPES
Develop a program to draw various shapes as pre requested by user.

4.1 Detail
On the earth, every thing having its own shape those are either natural or artificial. Shape defines the
category of things as well as making a space in the world for its existence. We will practice here for drawing
a different shape.

Expected Output:

1. Circle
2. Square
3. Rectangle
4. Triangle
5. Pentagonal
6. Hexagonal

Select the options to draw a shape: 3

Enter the size of shape (>= 20): 22

4.2 Documentation
Write a paper on program with description or detail understanding of logic.
5. RANDOMIZATION
Random strings can be unique. Used in computing, a random string generator can also be called a
random character string generator. This is an important tool if you want to generate a unique set of
strings. The utility generates a sequence that lacks a pattern and is random.

5.1 Detail
Develop a program that generate user defined numbers of random strings with below conditions.

1. String must be a fixed-length of 32.


2. String must be alfa-numeric (no special chars allowed).
3. String must be defined as a pattern of UUID-4.
4. One string per line to be displayed.
5. Every string must be unique.
6. Each character of string must be in small letter.

Note: Inbuilt UUID generator function will not be used.

Expected Output:

Please enter any number (>0) to generate the set of random strings: 4

67334c88-07a2-4bd1-a3b1-01f0cf152c76
cb406dc8-393d-427a-94fc-bc10abc486d7
7025d403-1ff7-4f73-8927-9ef7dbfe54b3
4826a7c2-42fc-49e5-9a23-60f19bcbc74b

5.2 Documentation
Write a paper on program with description or detail understanding of logic.

You might also like