This repository contains a collection of functions implemented in Java, focusing on string manipulation, numeric problem-solving and other basic programs. The repository includes the main classes: StringProblems
, NumProb
, BasicPrograms
and Patterns
. Each class is designed to perform a set of operations that can be useful in various programming contexts, for last minute java programming revision.
The StringProblems
class contains basic string manipulation methods, including:
- Reversing a String: Reverses the characters in a string.
- Palindrome Check: Verifies if a string is a palindrome.
- String Concatenation: Concatenates two strings together.
- Additional String Operations: Includes other string handling methods.
The NumProb
class provides solutions to various numeric problems, such as:
- Fibonacci Series Generation: Generates the Fibonacci sequence up to a specified term.
- Factorial Calculation: Computes the factorial of a given number.
- Prime Number Check: Checks if a number is prime.
- Palindrome Number Check: Verifies if a number is a palindrome.
- Greatest Common Divisor (GCD) and Least Common Multiple (LCM) calculation.
- Number Conversion: Converts numbers between binary, decimal, and octal formats.
- Area Calculation: Calculates the area of geometric shapes (circle, rectangle, etc.).
- Array Sorting: Implements sorting algorithms such as bubble sort, insertion sort, and merge sort.
The BasicPrograms
class provides the following additional functionalities:
-
Binary Addition
- Method:
addBin(String bin1, String bin2)
- Description: Adds two binary strings and returns the result as a binary string.
- Method:
-
Prime Number Check
- Method:
isPrime(int n)
- Description: Checks if a number
n
is prime.
- Method:
-
Prime Series Generation
- Method:
primeSeries(int n)
- Description: Generates an array of the first
n
prime numbers.
- Method:
-
Fibonacci Number at Position
- Method:
fib(int num)
- Description: Computes the Fibonacci number at a specified position
num
.
- Method:
-
Fibonacci Series Generation
- Method:
fibSeries(int num)
- Description: Generates an array containing the first
num
terms of the Fibonacci series.
- Method:
-
Sum of Even Fibonacci Terms
- Method:
evenSumofFibSeries(int N)
- Description: Computes the sum of Fibonacci numbers at even indices up to the
2 * N
-th term.
- Method:
-
Neon Number Check
- Method:
Neon(int num)
- Description: Checks if a number is a neon number, where the sum of the digits of its square equals the number itself.
- Method:
-
Vowel or Consonant Check
- Method:
VowelOrConsonant(char ch)
- Description: Checks if a character is a vowel or consonant.
- Method:
The Patterns
class provides functions to print various patterns of stars and numbers:
-
StarRightTriangle
- Description: Prints a right-aligned triangle of stars.
- Example:
* * * * * * * * * *
-
StarLeftTriangle
- Description: Prints a left-aligned triangle of stars.
- Example:
* * * * * * * * * *
-
NumPyramid
- Description: Prints a pyramid of numbers incrementally from the top row down.
- Example:
1 2 3 2 3 4 5 4 3
-
RevPyramid
- Description: Prints a reverse pyramid of stars.
- Example:
******* ***** *** *
-
Pyramid
- Description: Prints an upright pyramid of stars.
-
UpperStarTriangle
- Description: Prints an upper triangle of stars.
-
SpiralMatrix
- Description: Fills a square matrix with numbers in a spiral order.
- Example (for
n = 3
):1 2 3 8 9 4 7 6 5
-
Diamond
- Description: Prints a diamond shape with stars.
-
DownwardRightTriangle
- Description: Prints a right triangle pointing downward.
-
DownwardPyramidMirror
- Description: Prints a mirrored downward pyramid pattern.
-
PascalsTriangle
- Description: Prints Pascal's triangle up to
n
rows.
- Description: Prints Pascal's triangle up to
-
HollowRectangle
- Description: Prints a hollow rectangle with specified dimensions.
-
HollowSquare
- Description: Prints a hollow square with stars around the edges.
-
SquareWithDiagonals
- Description: Prints a square pattern with diagonals filled in with stars.
-
FlippedRightTriangle
- Description: Prints a right triangle with flipped alignment.