Niven (Harshad) Number Program in Java for ICSE Class 10
A Niven (or Harshad) number is a positive integer n divisible by the sum of its decimal digits S(n), satisfying n % S(n) == 0. For instance, 156 has digit ...
Compile-ready BlueJ code, CISCE Variable Description Tables (VDT), step-by-step dry runs & interactive MCQs.
A Niven (or Harshad) number is a positive integer n divisible by the sum of its decimal digits S(n), satisfying n % S(n) == 0. For instance, 156 has digit ...
An Automorphic number is a non-negative integer n whose square n * n ends with the exact digits of n itselfβsuch as 5 (25), 25 (625), 76 (5776), and 376 (1...
A Spy number is a positive integer whose sum of digits equals the product of its digitsβfor example, 1124 has digit sum 1 + 1 + 2 + 4 = 8 and digit product...
A Duck number is a positive integer that contains at least one digit '0', provided '0' does not appear as a leading digitβso 305 and 4021 are Duck numbers,...
A Pronic (oblong or heteromecic) number is the product of two consecutive non-negative integers k * (k + 1), generating 0, 2, 6, 12, 20, 30, 42, 56, and so...
A Neon number is a non-negative integer n whose square n^2 has a digit sum equal to n itself. Remarkably, in base 10 only three Neon numbers exist: 0 (0^2 ...
An N-digit Armstrong (narcissistic) number equals the sum of its digits each raised to the power Nβfor 3-digit numbers like 153, 1^3 + 5^3 + 3^3 = 153, and...
A Palindrome number reads identically forwards and backwardsβsuch as 121, 1331, and 9009. In Java BlueJ, copy input `num` into `temp`, reverse the digits i...
A natural number greater than 1 is Prime if it has exactly two positive divisors (1 and itself), and Composite if it has more than two divisors; integers `...
An Emirp ("prime" spelled backwards) is a prime number that produces a DIFFERENT prime number when its base-10 digits are reversedβsuch as 13 (31), 17 (71)...
A Happy Number is a positive integer that eventually reduces to 1 when repeatedly replaced by the sum of the squares of its digits. Any unhappy integer ent...
A Magic Number is a positive integer whose repeated sum of digits eventually collapses to the single digit 1, such as 19, 28, or 1729. Using recursion in J...
A Disarium Number equals the sum of its digits raised to their respective 1-based left-to-right positions. For instance, 135 is a Disarium Number because 1...
A positive integer N is called a Sunny Number when N + 1 is a perfect square. Examples include 3 (since 3 + 1 = 4 = 2^2), 8 (since 8 + 1 = 9 = 3^2), and 15...
A Tech Number has an even number of digits such that splitting the number into two equal halves, adding them, and squaring the sum reproduces the original ...
A positive integer N with d digits is a Kaprekar Number if N squared can be split into two partsβa right part of d digits and a non-empty left partβwhose s...
An Evil Number is a non-negative integer whose binary representation contains an even number of 1s; numbers with an odd count of 1s are called Odious Numbe...
A Fascinating Number is an integer of three or more digits such that concatenating the number with its double (2 * n) and triple (3 * n) yields a 9-digit s...
A Smith Number is a composite positive integer whose sum of digits equals the sum of the digits of all its prime factors (counted with multiplicity). For i...
Twin Primes are pairs of prime numbers whose absolute difference is 2, such as (3, 5), (5, 7), (11, 13), and (17, 19). To print all Twin Prime pairs inside...
A Circular Prime is a positive integer greater than 1 that remains prime under every cyclic rotation of its digits. For example, 1193 produces the rotation...
A positive integer is classified by comparing the sum of its proper divisors (all positive factors excluding the number itself) against the original number...
In CISCE ICSE Computer Applications, a Buzz number is any integer that is either divisible by 7 or ends with the digit 7. Using Java arithmetic operators, ...
When an integer between 10 and 99 equals the sum of its digits added to the product of those digits, ICSE papers call it a Special Two-Digit Number. For th...
Known interchangeably as a Peterson, Strong, or Factorion number in CISCE syllabi, a Krishnamurthy number matches the sum of the factorials of its individu...
The Euclidean algorithm computes the Highest Common Factor (HCF), or Greatest Common Divisor (GCD), of two positive integers through repeated remainder div...
Two positive integers `x` and `y` are co-prime (relatively prime) when their Highest Common Factor equals `1`, meaning they share no common factor above un...
Prime factorization breaks an integer greater than `1` into prime divisors whose product reconstructs the original number. A `for` loop tests divisors `d` ...
Manual base conversion in ICSE Java uses positional place values instead of `Integer.toBinaryString()` or `Integer.parseInt(s, 2)`. To convert Binary to De...
An Ugly number (also called a Hamming number) is a positive integer whose only prime factors are `2`, `3`, or `5`, with `1` treated as an Ugly number by co...
Floyd's Triangle is a right-angled triangular array of consecutive natural numbers starting from 1, where row i prints exactly i integers. In Java BlueJ, y...
Pascal's Triangle arranges binomial coefficients C(i, j) in a centered pyramid where each row begins and ends with 1, and every interior value equals the s...
A Diamond Star Pattern combines an upright centered pyramid of n rows with an inverted centered pyramid of n - 1 rows, totaling 2n - 1 lines. For any row i...
A Hollow Square or Rectangle Star Pattern prints asterisks exclusively along the four outer boundaries of an r-by-c grid while filling every interior cell ...
The classic right-angled number triangle (1 / 1 2 / 1 2 3) uses two nested for loops where the outer loop i iterates from 1 to rows and the inner loop j re...
Inverted pyramid and reverse number patterns reverse vertical growth by initializing the outer loop i at n and decrementing with i-- until i >= 1. For a ce...
Alphabet triangle patterns (A / A B / A B C) combine nested for loops with ASCII character arithmetic in Java. Since uppercase 'A' corresponds to ASCII cod...
The Binary 1-0-1 Triangle alternates 1 and 0 in a checkerboard pattern (1 / 0 1 / 1 0 1 / 0 1 0 1) using coordinate parity. With outer row index i and inne...
A Palindromic Number Pyramid (1 / 121 / 12321) places three sequential inner loops inside an outer loop i from 1 to n. First, loop s prints n - i leading s...
The Butterfly Star Pattern renders symmetrical upper and lower halves across 2 * n rows. Each row i (climbing 1 to n in the upper phase, then stepping n do...
The Fibonacci sequence starts with 0 and 1, where every subsequent term equals the sum of the preceding two terms: F(n) = F(n - 1) + F(n - 2). In ICSE Clas...
Tribonacci numbers extend Fibonacci by summing three preceding terms: T(n) = T(n - 1) + T(n - 2) + T(n - 3), seeded at 0, 1, 1 (yielding 0, 1, 1, 2, 4, 7, ...
To compute S = 1! + 2! + 3! + ... + n! efficiently in Java, maintain a running factorial variable fact = 1 inside a single for loop from 1 to n. On every i...
The alternating power series S = x - x^2/2! + x^3/3! - ... +/- x^n/n! flips sign on every iteration using a multiplier sign = 1 toggled via sign *= -1. Bec...
In Java, writing 1 / i when i is an int greater than 1 triggers integer division and evaluates to 0, collapsing the harmonic series H(n) = 1 + 1/2 + 1/3 + ...
ICSE Class 10 Section B frequently tests menu-driven switch-case programs where the user chooses between two distinct series, such as S1 = 1 + 2 + 3 + ... ...
Nested-loop word patterns such as the BLUEJ triangle print progressive prefixes of a String using word.length() and word.charAt(j). An outer loop controls ...
Each term in the repdigit series 9 + 99 + 999 + ... (n terms) follows the exact integer recurrence term = term * 10 + 9, starting from term = 0. Accumulati...
An ICSE combined Prime and Fibonacci menu program pairs a switch dispatcher with two independent algorithms: trial-division primality testing up to sqrt(nu...
Between 100 and 999, an Armstrong number equals the sum of the cubes of its digits (153, 370, 371, 407), while a Palindrome number reads identically forwar...
In ICSE Computer Applications, a **Special Word** begins and ends with the same character (for example, `WINDOW` or `COMIC`), whereas a **Palindrome Word**...
To encode a word into **Piglatin** in ICSE Java, locate the **first vowel** (`A, E, I, O, U`) scanning left to right. Split the uppercase word at that inde...
To abbreviate a full name such as `Subhash Chandra Bose` into `S.C.B.` in ICSE Java, prepend a leading space (`" " + name.trim()`), scan every character, a...
To find both the **longest** and **shortest** words in a sentence in ICSE Java, append one trailing space (`sent = sc.nextLine().trim() + " "`) so the fina...
To classify every character in a sentence in ICSE Java, loop from `0` to `str.length() - 1` and inspect `ch = str.charAt(i)` with `java.lang.Character` wra...
To toggle character case in Java for ICSE Section B exams, traverse the input string from index `0` to `length() - 1` using `charAt(i)`. Test each characte...
Replacing vowels in Java involves scanning each character of a string with `charAt(i)` and checking membership against `'A', 'E', 'I', 'O', 'U'` (plus lowe...
Two strings are anagrams if they contain identical letters with identical frequencies in any order, such as `"Listen"` and `"Silent"`. In ICSE Java, normal...
A Unique String contains no repeated characters anywhere in the word or sentenceβfor example, `"COMPUTER"` is unique, and `"PROGRAM"` is not because `'R'` ...
To inspect word boundaries in an ICSE sentence, extract each word cleanly using `StringTokenizer` (or space tracking) and strip punctuation such as `.` or ...
To sort words of a sentence alphabetically in Java, tokenize the input string into individual words using StringTokenizer or space-index slicing, store the...
Removing duplicate characters from a Java string while preserving original order requires scanning each character left to right and checking whether it alr...
To reverse each word in a sentence without changing word order in Java, extract one word at a time and prepend each incoming character ahead of the current...
A double-letter sequence occurs whenever two adjacent characters in an uppercase-normalized string are identical letters, such as 'B' followed by 'B' in "R...
In ICSE Java, a Magic String (or Magic Word) is a word containing at least one pair of consecutive alphabetical letters side by side, such as 'A' followed ...
A Happy Word in ICSE Java is a word whose concatenated alphabet position values form a Happy Number. Converting each uppercase letter via `ch - 'A' + 1` ma...
A Caesar Cipher shifts every alphabet character forward by a fixed key while wrapping past Z back to A. In Java, convert each letter to a 0β25 index using ...
Converting a sentence to Title Case in ICSE Java requires capitalizing the first character of every word while converting remaining letters to lowercase. T...
To count the frequency of every alphabet AβZ in a Java string, normalize the text with `toUpperCase()` and allocate an `int` array of size 26 initialized t...
To split letters and digits from a mixed Java string, inspect each character inside a single `for` loop using `Character.isLetter(ch)` and `Character.isDig...
Bubble Sort arranges an integer array in ascending or descending order by repeatedly comparing adjacent elements `arr[j]` and `arr[j+1]` and swapping them ...
Because Java forbids `<` or `>` on `String` objects, sorting city names or student lists with Bubble Sort requires `compareTo()` or `compareToIgnoreCase()`...
Selection Sort divides an array into a growing sorted prefix on the left and an unsorted suffix on the right. In each outer pass `i` from `0` to `n-2`, it ...
Binary Search locates a target key inside an already sorted array by repeatedly dividing the active search window in half. Starting with `low = 0` and `hig...
Linear Search inspects an array sequentially from index `0` to `n-1` and works on both sorted and unsorted arrays. Unlike a first-match search that exits e...
Combining two single-dimensional arrays in ICSE Java requires allocating a third destination array of size m + n, where m and n are the input lengths. For ...
Java arrays have fixed physical length, so removing duplicates means filtering unique elements while maintaining an updated logical count u. Using a clean ...
To find the second largest and second smallest values in a Java array in a single traversal without sorting, initialize max1 and max2 to Integer.MIN_VALUE,...
Cyclic rotation shifts every element of an array by k steps while wrapping overflowed items around to the opposite end. First normalize k = k % n so rotati...
Parallel arrays link related student records across separate arrays using a shared index i, so name[i] always owns marks[i]. To find the class topper, trac...
To compute row-wise and column-wise totals of an `M x N` integer matrix in Java, use two separate nested `for` loops. Keep the outer loop variable `i` fixe...
In a `4 x 4` square matrix `M[4][4]`, elements on the left (primary) diagonal satisfy `i == j`, whereas elements on the right (secondary) diagonal satisfy ...
The transpose of an `M x N` matrix `A` is a new `N x M` matrix `T` obtained by turning every row into a column using the assignment `T[j][i] = A[i][j]`. Be...
A square `N x N` matrix `M` is **symmetric** if `M[i][j] == M[j][i]` for every pair of indices (`M = M^T`), and **skew-symmetric** if `M[i][j] == -M[j][i]`...
Boundary elements of an `M x N` matrix occupy the outer frame where `i == 0`, `i == M - 1`, `j == 0`, or `j == N - 1`. Interior cells (`1 <= i <= M - 2` an...
An ISBN-10 code is valid when it has ten characters, nine digits followed by a digit or 'X' for 10, whose weighted positional sum divides evenly by 11. For...
Parallel arrays store paired records across separate 1D arrays where identical index positions link each key to its matching value. In this ICSE Java progr...
The ICSE Seven Wonders problem pairs seven monuments in wonders[] with their host nations in a parallel countries[] array of size 7. After reading a countr...
A saddle point in a 2D matrix is an element that is simultaneously the smallest value in its row and the largest value in its column. To locate it in Java,...
Splitting one Java array into separate even and odd arrays is cleanest in two passes. First, scan arr[] to count even (ec) and odd (oc) elements via arr[i]...
Method overloading in Java lets a single class define multiple area() methods sharing the same name while differing in parameter count, data types, or para...
To overload volume() for a sphere, cylinder, and cone in ICSE Java, each method keeps the name volume while changing its parameter listβone double for a sp...
In the ICSE board check() overloading problem, a class defines two void methods named check: check(String str, char ch) counts how many times ch appears in...
The ICSE polygon() overloading task pairs three void methods with distinct parameter lists to render console patterns via nested for loops: polygon(int n, ...
The ICSE ElectricBill class models slab-based utility billing using instance variables (n, units, bill) and three member methods: accept(), calculate(), an...
In ICSE Computer Applications, the RailwayTicket class models passenger booking data using five instance variables: name, coach, mobno, amt, and totalamt. ...
The ICSE BookFair class computes net book prices using a default constructor and three percentage discount brackets. BookFair() initializes Bname to an emp...
The ICSE ShowRoom class calculates festival shopping discounts across four purchase brackets using five instance variables: name, mobno, cost, dis, and amo...
The ICSE MovieMagic class classifies a film's box-office verdict from a float popularity score between 0.0 and 5.0. Its default constructor initializes yea...
Both ParkingLot and Library are classic ICSE Section B rate-calculation classes that contrast incremental versus flat billing. ParkingLot charges Rs. 3.00 ...
In CISCE ICSE Section B, class-design questions such as FruitJuice and Courier test object-oriented encapsulation using four parts: instance variables, a d...
An ICSE Employee Salary program computes Dearness Allowance (DA), House Rent Allowance (HRA), and Provident Fund (PF) as percentages of basic pay using dou...
In ICSE Java, Call by Value passes a copy of a primitive argument to a method, leaving the original variable unchanged in the caller. Passing an array or o...
Java Wrapper Classes in java.lang enclose primitive types inside objects so they work with library utilities and conversions. In ICSE exams, Character meth...
Scanner.nextLine() skips string input after nextInt() or nextDouble() because numeric token methods leave the trailing Enter newline character inside the i...
In Java, prefix operators (`++x`, `--x`) follow the change-then-use rule, updating the variable before supplying its value to the expression. Postfix opera...
Java's ternary operator (`condition ? expr1 : expr2`) is right-associative and must return a value compatible with the receiving variable, unlike `if-else`...
A Java constructor shares the exact class name, carries no return typeβnot even `void`βand runs automatically when `new` creates an object to initialize in...
Java access specifiers control member visibility across classes and packages: `private` restricts access strictly inside the declaring class, package-priva...
CISCE Section B awards 15 marks per program across four questions, reserving dedicated marks in every program for documentationβspecifically a Variable Des...
Book a free 60-minute diagnostic trial with IIT/NIT specialist mentors.