Java Project Case Study Requirements
Java Project Case Study Requirements
Aim/Objective
To develop a Java program that accepts three distinct integers from the user and identifies the
maximum value among them using the if-else if-else construct.
Algorithm/Logic
The program logic utilizes a series of comparison operators. First, the first number is
compared with and . If is found to be greater than or equal to both, it is declared the
greatest. If this condition fails, it implies is not the greatest, thereby narrowing the search
space to and . A subsequent comparison determines if is greater than or equal to . If
so, is the greatest; otherwise, by the process of elimination, must be the largest integer.
Java Program
Java
import [Link];
/*
* This program identifies the largest of three numbers.
* It demonstrates the use of logical AND (&&) to combine
* multiple comparison criteria.
*/
public class GreatestNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]); // Creating Scanner object for input
[Link]("Enter first number: ");
int a = [Link]();
[Link]("Enter second number: ");
int b = [Link]();
[Link]("Enter third number: ");
int c = [Link]();
// Evaluating conditions for the greatest number
if (a >= b && a >= c) {
[Link]("The greatest number is: " + a);
} else if (b >= a && b >= c) {
[Link]("The greatest number is: " + b);
} else {
[Link]("The greatest number is: " + c);
}
}
}
Result/Conclusion
The program successfully identifies the greatest of three numbers through the implementation
of logical conjunctions and relational operators.3
Aim/Objective
Algorithm/Logic
The logic resides in the comparison of the input value against the zero reference point. A value
Java Program
Java
import [Link];
/*
* Program to classify a number based on its sign.
* Uses conditional branching for categorization.
*/
public class CheckSign {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a numerical value: ");
double num = [Link](); // Reading the number
// Conditional checks for positive, negative, or zero
if (num > 0) {
[Link](num + " is Positive.");
} else if (num < 0) {
[Link](num + " is Negative.");
} else {
[Link]("The value is Zero.");
}
}
}
Result/Conclusion
Effective classification of numerical polarity is achieved through the use of standard conditional
pathways.
Aim/Objective
To determine the parity (odd or even) of an integer input using the modulus operator.
Algorithm/Logic
Java Program
Java
import [Link];
/*
* This program checks for parity.
* It uses the modulus operator (%) to find the remainder.
*/
public class ParityCheck {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
// Checking if remainder upon division by 2 is zero
if (n % 2 == 0) {
[Link](n + " is an Even number.");
} else {
[Link](n + " is an Odd number.");
}
}
}
Name of the Variable Data Type Purpose/Description
Result/Conclusion
The program correctly identifies the parity of an integer using the arithmetic modulus
operation.
Aim/Objective
To create an interactive arithmetic calculator that allows users to select an operation from a
menu and perform it on two provided operands.
Algorithm/Logic
The program displays a menu of four options: addition, subtraction, multiplication, and division.
The user selects a numerical option which is then passed to a switch block. Each case within
the switch handles a specific arithmetic operation. Crucially, the division case includes a safety
check to prevent division by zero, which would otherwise result in an ArithmeticException.
Java Program
Java
import [Link];
/*
* Interactive calculator using switch-case.
* Provides modular arithmetic functionality.
*/
public class SimpleCalculator {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
// Displaying operation menu
[Link]("--- Simple Calculator ---");
[Link]("1. Addition (+)");
[Link]("2. Subtraction (-)");
[Link]("3. Multiplication (*)");
[Link]("4. Division (/)");
[Link]("Select an option (1-4): ");
int choice = [Link]();
[Link]("Enter first operand: ");
double num1 = [Link]();
[Link]("Enter second operand: ");
double num2 = [Link]();
// Performing operation based on choice
switch (choice) {
case 1:
[Link]("Result: " + (num1 + num2));
break;
case 2:
[Link]("Result: " + (num1 - num2));
break;
case 3:
[Link]("Result: " + (num1 * num2));
break;
case 4:
if (num2!= 0) {
[Link]("Result: " + (num1 / num2));
} else {
[Link]("Error: Division by zero is undefined.");
}
break;
default:
[Link]("Error: Invalid operation selected.");
}
}
}
Name of the Variable Data Type Purpose/Description
Result/Conclusion
A modular arithmetic interface was successfully implemented using the switch-case control
structure.
Aim/Objective
To calculate the total sum of all individual digits within a user-defined integer.
Algorithm/Logic
The algorithm employs a while loop that continues as long as the number is not zero. In each
iteration, the last digit is extracted using the modulus operator (n % 10) and added to a
Java Program
Java
import [Link];
/*
* Program to calculate digit summation.
* Demonstrates loop-based digit extraction.
*/
public class DigitSum {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a positive integer: ");
int n = [Link]();
int sum = 0;
int original = n;
// Iterative extraction and summation
while (n > 0) {
int d = n % 10; // Extract last digit
sum += d; // Add to running total
n /= 10; // Remove processed digit
}
[Link]("Sum of digits of " + original + " is: " + sum);
}
}
Result/Conclusion
The program efficiently computes the sum of digits through iterative mathematical
decomposition.7
6. Reverse of a Number
The reversal of an integer is the first step toward checking for palindromes or performing
certain encryption transformations. It involves not just extraction but the reconstruction of an
integer in a different order.2
Aim/Objective
Algorithm/Logic
Similar to the sum of digits, this logic uses the n % 10 and n / 10 pattern. However, as each digit
is extracted, the previously accumulated rev variable is multiplied by 10 to shift its digits to the
left, and the new digit is added. For example, if the input is 123, the process is:
Java Program
Java
import [Link];
/*
* Numerical reversal implementation.
* Uses place-value shifting to reconstruct the integer.
*/
public class Reversal {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an integer: ");
int n = [Link]();
int rev = 0;
// Reconstructing reversed number
while (n!= 0) {
int d = n % 10;
rev = (rev * 10) + d; // Shift and add
n /= 10;
}
[Link]("Reversed value: " + rev);
}
}
Result/Conclusion
Aim/Objective
Algorithm/Logic
The program first creates a copy of the input integer in a temporary variable temp because the
reversal process destroys the original value through repeated division. After calculating the
reversed number rev using the logic of digit extraction and place shifting, the program
performs an equality check between temp and rev. If they are identical, the number is a
palindrome.
Java Program
Java
import [Link];
/*
* Palindrome verification logic.
* Compares the original value with its reversed form.
*/
public class PalindromeCheck {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number to check: ");
int n = [Link]();
int temp = n; // Preserving original value
int rev = 0;
// Reversal logic
while (n > 0) {
rev = (rev * 10) + (n % 10);
n /= 10;
}
// Symmetry verification
if (temp == rev) {
[Link](temp + " is a Palindrome Number.");
} else {
[Link](temp + " is not a Palindrome Number.");
}
}
}
Result/Conclusion
The program correctly identifies palindromic symmetry in integers using reconstruction logic.2
8. Prime Number
Primality is a fundamental property in number theory and cryptography. Checking for primality
involves searching for factors beyond the trivial divisors (1 and the number itself).2
Aim/Objective
To verify if an input number is prime, meaning it has exactly two distinct factors: 1 and itself.
Algorithm/Logic
loop could check all numbers from 1 to , efficiency is improved by checking factors only up to
or . The implemented logic uses a counter to count divisors from 1 to . If the
counter equals 2 at the end, the number is prime.
Java Program
Java
import [Link];
/*
* Primality testing using factor counting.
* A prime number has exactly two factors (1 and itself).
*/
public class PrimeCheck {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int n = [Link]();
int count = 0;
// Counting divisors from 1 to n
for (int i = 1; i <= n; i++) {
if (n % i == 0) {
count++;
}
}
if (count == 2) {
[Link](n + " is a Prime Number.");
} else {
[Link](n + " is not a Prime Number.");
}
}
}
Result/Conclusion
The program accurately classifies primes by validating the count of their mathematical factors.3
9. Fibonacci Series
The Fibonacci sequence is a classic example of additive growth and is frequently used to teach
loop structures and state-variable updates.3
Aim/Objective
Algorithm/Logic
The sequence starts with two predefined terms: 0 and 1. Each subsequent term is the sum of
the preceding two. To generate the series, three variables are used: a (first term), b (second
term), and c (current term). In each iteration of the loop, c is calculated as and printed.
Then, the variables are shifted: a takes the value of b, and b takes the value of c, preparing the
state for the next addition.
Java Program
Java
import [Link];
/*
* Fibonacci series generation.
* Demonstrates iterative state-shifting logic.
*/
public class Fibonacci {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter the number of terms: ");
int n = [Link]();
int a = 0, b = 1;
[Link]("Series: " + a + ", " + b);
// Iterative addition and value shifting
for (int i = 3; i <= n; i++) {
int c = a + b;
[Link](", " + c);
a = b; // Shifting state
b = c;
}
[Link]();
}
}
Result/Conclusion
The program successfully generates the Fibonacci sequence by iteratively updating preceding
term values.3
Aim/Objective
To print a numeric right-angled triangle where each row contains increasing values.
Algorithm/Logic
Nested loops are the engine of this program. The outer loop (i) controls the number of rows.
For each row i, the inner loop (j) iterates from 1 to i. This means the first row has one column,
the second has two, and so on. The value of j is printed in each step of the inner loop, creating a
sequence of across the columns. A [Link]() call after the inner loop
ensures that each new row starts on a fresh line.
Java Program
Java
/*
* Nested loop demonstration for pattern printing.
* Prints a numeric triangle of a fixed size.
*/
public class NumericPattern {
public static void main(String args) {
int rows = 5;
// Outer loop manages vertical rows
for (int i = 1; i <= rows; i++) {
// Inner loop manages horizontal columns
for (int j = 1; j <= i; j++) {
[Link](j + " ");
}
[Link](); // Line break after each row
}
}
}
Result/Conclusion
A structured numeric pattern was successfully generated using nested iterative loops.11
2 -5 -5.0 is Negative.
3 17 17 is an Odd number.
8 13 13 is a Prime Number.
9 5 Series: 0, 1, 1, 2, 3
10 (None) 1 \n 1 2 \n 1 2 3...
Aim/Objective
To determine if a 3-digit integer follows the Armstrong property ( ).
Algorithm/Logic
The input number is preserved in a variable copy. The program then iterates through the digits
of n. For every digit , the cube is calculated and added to an accumulator sum.
After the loop, sum is compared with copy. If equal, the condition for an Armstrong number is
satisfied.
Java Program
Java
import [Link];
/*
* Armstrong number validation.
* Applicable to 3-digit integers for cube-sum verification.
*/
public class ArmstrongNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a 3-digit number: ");
int n = [Link]();
int copy = n;
int sum = 0;
// Extracting digits and summing their cubes
while (n > 0) {
int d = n % 10;
sum += (d * d * d); // Cube addition
n /= 10;
}
if (sum == copy) {
[Link](copy + " is an Armstrong Number.");
} else {
[Link](copy + " is not an Armstrong Number.");
}
}
}
Result/Conclusion
The program identifies Armstrong numbers by evaluating the cubic sum of their digits.2
Aim/Objective
To check if a number is automorphic by comparing its digits with the trailing digits of its square.
Algorithm/Logic
First, the number of digits in the input is calculated (let this be ). Next, the square of is
computed. To extract the last digits of the square, the program uses the formula
Java Program
Java
import [Link];
/*
* Automorphic number verification.
* Uses [Link] for dynamic digit extraction from square.
*/
public class AutomorphicNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int n = [Link]();
int sq = n * n;
// Counting digits to determine the divisor
int temp = n, c = 0;
while (temp > 0) {
c++;
temp /= 10;
}
// Extracting matching number of digits from the square
int last = sq % (int)[Link](10, c);
if (last == n) {
[Link](n + " is an Automorphic Number.");
} else {
[Link](n + " is not an Automorphic Number.");
}
}
}
Result/Conclusion
The program validates the automorphic property using dynamic power-based modulus
extraction.1
Aim/Objective
To implement an algorithm that recursively sums digits until a single-digit value is reached, then
verifies if that value is 1.
Algorithm/Logic
The program uses a while loop that continues as long as the number is greater than 9 (meaning
it has more than one digit). Inside, another loop calculates the sum of the digits. Once the inner
loop finishes, the outer variable is updated with the sum. This "collapsing" process repeats until
a single digit remains. If the single digit is 1, it is a magic number.
Java Program
Java
import [Link];
/*
* Recursive digit summation logic.
* A number is magic if its final digital root is 1.
*/
public class MagicNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int n = [Link]();
int sum = n;
// Loop until a single digit is obtained
while (sum > 9) {
int temp = sum;
sum = 0;
while (temp > 0) {
sum += (temp % 10);
temp /= 10;
}
}
if (sum == 1) {
[Link]("Magic Number");
} else {
[Link]("Not a Magic Number");
}
}
}
Aim/Objective
To check for the presence of the digit zero in a number while ensuring it is not a leading zero.
Algorithm/Logic
While this can be handled mathematically, a "smart logic" approach uses String manipulation.
The program reads the input as a string. It checks the character at index 0. If it is '0', the
number is immediately disqualified. Then, it iterates through the rest of the string searching for
'0'. If a zero is found after the first position, it is a Duck Number.
Java Program
Java
import [Link];
/*
* Duck number identification using string indexing.
* Ensures zero is present but not in the leading position.
*/
public class DuckNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
String s = [Link]();
boolean isDuck = false;
// Leading zero check
if ([Link](0)!= '0') {
for (int i = 1; i < [Link](); i++) {
if ([Link](i) == '0') {
isDuck = true;
break;
}
}
}
if (isDuck) {
[Link]("Duck Number");
} else {
[Link]("Not a Duck Number");
}
}
}
Result/Conclusion
String-based index verification efficiently identifies Duck Numbers while handling leading zero
constraints.9
Aim/Objective
The program initializes sum = 0 and prod = 1. It extracts digits iteratively using % 10. Each digit is
added to sum and multiplied into prod. After processing all digits, the two variables are
compared.
Java Program
Java
import [Link];
/*
* Logic to compare digit sum vs digit product.
* Common interview and academic logic puzzle.
*/
public class SpyNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int n = [Link]();
int sum = 0, prod = 1;
// Simultaneous calculation of sum and product
while (n > 0) {
int d = n % 10;
sum += d;
prod *= d;
n /= 10;
}
if (sum == prod) {
[Link]("Spy Number");
} else {
[Link]("Not a Spy Number");
}
}
}
Name of the Variable Data Type Purpose/Description
Result/Conclusion
Spy numbers are accurately identified by calculating digit-level parity between addition and
multiplication.4
Aim/Objective
Algorithm/Logic
First, calculate the sum of the digits using the standard iterative extraction method. Then, use
the modulus operator to check if the original number divided by this sum yields a remainder of
0.
Java Program
Java
import [Link];
/*
* Divisibility check based on digit sum.
* Also known as Harshad Number verification.
*/
public class NivenNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int n = [Link]();
int temp = n, sum = 0;
// Calculating digit sum
while (temp > 0) {
sum += (temp % 10);
temp /= 10;
}
// Final divisibility check
if (n % sum == 0) {
[Link](n + " is a Niven Number.");
} else {
[Link](n + " is not a Niven Number.");
}
}
}
Result/Conclusion
Niven Number status is confirmed through the calculation of digit-sum divisibility.2
.17
Aim/Objective
Algorithm/Logic
The program iterates from 1 up to the input number (or its square root for efficiency). In each
step, it checks if matches the input. If a match is found, the loop terminates and
the number is declared Pronic.
Java Program
Java
import [Link];
/*
* Detection of product of consecutive integers.
* Examples include 6 (2x3), 12 (3x4).
*/
public class PronicNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int n = [Link]();
boolean isPronic = false;
// Searching for two consecutive factors
for (int i = 1; i <= n; i++) {
if (i * (i + 1) == n) {
isPronic = true;
break;
}
}
if (isPronic) {
[Link]("Pronic Number");
} else {
[Link]("Not a Pronic Number");
}
}
}
Result/Conclusion
Aim/Objective
To verify primality for both the input number and its reversed integer.
Algorithm/Logic
The program first checks if is prime. If so, it reverses the number to get rev. Then, it
performs a second primality check on rev. Only if both tests pass is the number "Twisted
Prime."
Java Program
Java
import [Link];
/*
* Dual primality test.
* Checks both original and reversed values.
*/
public class TwistedPrime {
// Utility method to check primality
public static boolean isPrime(int num) {
if (num < 2) return false;
for (int i = 2; i <= [Link](num); i++) {
if (num % i == 0) return false;
}
return true;
}
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter number: ");
int n = [Link]();
if (isPrime(n)) {
// Reversing the prime number
int temp = n, rev = 0;
while (temp > 0) {
rev = (rev * 10) + (temp % 10);
temp /= 10;
}
// Checking if reversed value is also prime
if (isPrime(rev)) {
[Link]("Twisted Prime");
} else {
[Link]("Prime but not Twisted");
}
} else {
[Link]("Not a Prime Number");
}
}
}
Result/Conclusion
The program identifies Twisted Primes by performing successive primality tests on inverted
digits.18
Aim/Objective
To compute the square of a number and verify if its digit sum matches the original input.
Algorithm/Logic
Square the number . Then, calculate the sum of the digits of the square using the
Java Program
Java
import [Link];
/*
* Square-digit summation logic.
* Rare number property mostly used in logic puzzles.
*/
public class NeonNumber {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter number: ");
int n = [Link]();
int sq = n * n;
int sum = 0;
// Calculating sum of digits of the square
while (sq > 0) {
sum += (sq % 10);
sq /= 10;
}
if (sum == n) {
[Link]("Neon Number");
} else {
[Link]("Not a Neon Number");
}
}
}
Result/Conclusion
Neon numbers are successfully identified through the summation of their square's digits.2
Aim/Objective
To check if a number is prime and, if not, find the immediate prime number that follows it.
Algorithm/Logic
The program first evaluates if the input is prime. If it is not, an infinite search loop starts from
. Each number in the sequence is tested for primality. The loop breaks immediately
when the first prime is encountered.
Java Program
Java
import [Link];
/*
* Primality check and successor search.
* Demonstrates a non-deterministic loop for prime identification.
*/
public class NextPrimeFinder {
public static boolean isPrime(int num) {
if (num < 2) return false;
for (int i = 2; i <= num / 2; i++) {
if (num % i == 0) return false;
}
return true;
}
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int n = [Link]();
if (isPrime(n)) {
[Link](n + " is prime.");
} else {
[Link](n + " is not prime.");
// Search for next prime
int next = n + 1;
while (!isPrime(next)) {
next++;
}
[Link]("The next prime is " + next);
}
}
}
Result/Conclusion
The program provides a robust method for finding consecutive primes in a numeric sequence.9
12 25 25 is an Automorphic Number.
13 28 Magic Number
16 18 18 is a Niven Number.
17 20 Pronic Number
18 13 Twisted Prime
19 9 Neon Number
Aim/Objective
Algorithm/Logic
The program defines a String variable containing digits. It then invokes the static method
parseInt() from the Integer class. To prove the conversion was successful, an arithmetic
operation is performed on the resulting integer.
Java Program
Java
/*
* Wrapper class demonstration for parsing.
* Converts String to primitive int.
*/
public class StringConversion {
public static void main(String args) {
String numStr = "2024";
// Static method parseInt converts String to int
int year = [Link](numStr);
[Link]("Original String: " + numStr);
[Link]("Year + 1: " + (year + 1));
}
}
Result/Conclusion
The conversion from String to integer is accurately performed using the Integer wrapper
class.21
Aim/Objective
Algorithm/Logic
Using the Character class, the program evaluates isLetter(ch) and isDigit(ch). If neither returns
true, the character is classified as a special symbol.
Java Program
Java
import [Link];
/*
* Character classification utility.
* Uses Character class static methods.
*/
public class CharCategory {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a character: ");
char ch = [Link]().charAt(0);
if ([Link](ch)) {
[Link](ch + " is a Letter.");
} else if ([Link](ch)) {
[Link](ch + " is a Digit.");
} else {
[Link](ch + " is a Special Character.");
}
}
}
Name of the Variable Data Type Purpose/Description
Result/Conclusion
Aim/Objective
Algorithm/Logic
The program accepts a character and first checks if it is an alphabet. If so, it further determines
its case using library methods.
Java Program
Java
import [Link];
/*
* Case detection logic.
* Demonstrates Character class case-checking methods.
*/
public class CaseVerifier {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter an alphabet: ");
char ch = [Link]().charAt(0);
if ([Link](ch)) {
[Link]("Character is Uppercase.");
} else if ([Link](ch)) {
[Link]("Character is Lowercase.");
} else {
[Link]("Input is not an alphabet.");
}
}
}
Result/Conclusion
Aim/Objective
To parse strings into integer and double formats correctly using wrapper methods.
Algorithm/Logic
The program parses one string into an int and another into a double. It then performs an
addition, demonstrating that the variables are now treated as numerical primitives by the JVM.
Java Program
Java
/*
* Mixed-type parsing demonstration.
* Parses strings into multiple primitive formats.
*/
public class ParseDemo {
public static void main(String args) {
String s1 = "100";
String s2 = "15.5";
// Parsing to int and double
int val1 = [Link](s1);
double val2 = [Link](s2);
[Link]("Combined result: " + (val1 + val2));
}
}
Result/Conclusion
Wrapper methods parseInt() and parseDouble() facilitate accurate type casting from string
data.22
Aim/Objective
Algorithm/Logic
The program takes a string s. It constructs a new string rev by iterating through the characters
of s from the last index to the first. Finally, it uses equalsIgnoreCase() to compare the two.
Java Program
Java
import [Link];
/*
* String reversal for palindrome check.
* Handles case sensitivity by ignoring case differences.
*/
public class StringPalindrome {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a word: ");
String s = [Link]();
String rev = "";
// Building reversed string
for (int i = [Link]() - 1; i >= 0; i--) {
rev += [Link](i);
}
if ([Link](rev)) {
[Link]("It is a Palindrome String.");
} else {
[Link]("It is not a Palindrome String.");
}
}
}
Result/Conclusion
Aim/Objective
To count the occurrences of vowels, consonants, digits, and whitespace in a given sentence.
Algorithm/Logic
The program converts the string to lowercase to simplify vowel checking. It iterates through
the string using charAt(i). For each character, it uses conditional statements to increment
relevant counters. Consonants are identified as characters that are letters but not vowels.
Java Program
Java
import [Link];
/*
* Sentence-level character analysis.
* Counts specific character types using condition checks.
*/
public class TextCounter {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence: ");
String s = [Link]().toLowerCase();
int v = 0, c = 0, d = 0, sp = 0;
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if ([Link](ch)) {
if ("aeiou".indexOf(ch)!= -1) v++;
else c++;
} else if ([Link](ch)) {
d++;
} else if (ch == ' ') {
sp++;
}
}
[Link]("Vowels: " + v + "\nConsonants: " + c);
[Link]("Digits: " + d + "\nSpaces: " + sp);
}
}
Result/Conclusion
Aim/Objective
Algorithm/Logic
The "smart logic" approach involves appending a space to the sentence to ensure the last word
is processed. The program iterates through the sentence; when a space is encountered, it
takes the current word accumulated in a temporary variable, reverses it, appends it to a result
string, and clears the temporary variable.
Java Program
Java
import [Link];
/*
* Word-level reversal logic.
* Maintains word positions while flipping internal characters.
*/
public class WordFlipper {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter sentence: ");
String s = [Link]() + " "; // Add space to detect last word
String word = "", result = "";
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if (ch!= ' ') {
word = ch + word; // Prepending reverses the word
} else {
result += word + " ";
word = ""; // Reset for next word
}
}
[Link]("Result: " + [Link]());
}
}
Result/Conclusion
Aim/Objective
Algorithm/Logic
The program splits the sentence into a string array. It then applies the Bubble Sort algorithm.
The compareTo() method is used to compare adjacent strings. If str[i].compareTo(str[j]) > 0, it
indicates that the words are out of alphabetical order and need to be swapped.
Java Program
Java
import [Link];
/*
* Lexicographical sorting using Bubble Sort.
* Compares strings using the compareTo method.
*/
public class LexicalSort {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence: ");
String s = [Link]();
String words = [Link](" ");
// Bubble sort for alphabetical order
for (int i = 0; i < [Link] - 1; i++) {
for (int j = 0; j < [Link] - 1 - i; j++) {
if (words[j].compareToIgnoreCase(words[j+1]) > 0) {
// Swapping words
String temp = words[j];
words[j] = words[j+1];
words[j+1] = temp;
}
}
}
[Link]("Alphabetical Order: ");
for (String w : words) {
[Link](w + " ");
}
[Link]();
}
}
Result/Conclusion
The program successfully sorts words lexicographically using the Bubble Sort algorithm and
the compareTo method.36
Section V: Arrays
Arrays allow for the storage and manipulation of contiguous datasets of the same type. This
section focuses on Single Dimensional Arrays (SDA) and basic algorithmic efficiency.1
Aim/Objective
To find the maximum and minimum elements, the total sum, and the mean of elements in a
one-dimensional array.
Algorithm/Logic
The program initializes max and min with the first element of the array. As it iterates through the
remaining elements, it updates these values if it finds a larger or smaller number, respectively.
Simultaneously, it adds each element to a sum variable. Finally, the average is calculated as sum
/ [Link].
Java Program
Java
import [Link];
/*
* SDA aggregate calculations.
* Finds range and mean of a dataset.
*/
public class ArrayStats {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter size of array: ");
int n = [Link]();
int arr = new int[n];
[Link]("Enter elements:");
for (int i = 0; i < n; i++) arr[i] = [Link]();
int max = arr, min = arr, sum = 0;
// One-pass traversal for all stats
for (int val : arr) {
if (val > max) max = val;
if (val < min) min = val;
sum += val;
}
[Link]("Maximum: " + max + "\nMinimum: " + min);
[Link]("Sum: " + sum + "\nAverage: " + (double)sum/n);
}
}
Result/Conclusion
The program efficiently performs multiple statistical operations in a single array traversal.41
Aim/Objective
To sort a numeric array in ascending order using Bubble Sort and subsequently find a target
value using Linear Search.
Algorithm/Logic
The program first implements Bubble Sort: it uses nested loops where the inner loop swaps
adjacent elements if they are in the wrong order. This "bubbles" the largest element to the end
of the array in each pass. After sorting, the program performs a Linear Search by comparing
the target key with every element until a match is found.
Java Program
Java
import [Link];
/*
* Sorting and searching implementation.
* Combines Bubble Sort with Linear Search logic.
*/
public class SortAndSearch {
public static void main(String args) {
Scanner sc = new Scanner([Link]);
int arr = {64, 34, 25, 12, 22, 11, 90};
// Bubble Sort Implementation
for (int i = 0; i < [Link] - 1; i++) {
for (int j = 0; j < [Link] - 1 - i; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
[Link]("Sorted Array: ");
for (int val : arr) [Link](val + " ");
[Link]("\nEnter number to search: ");
int key = [Link]();
int pos = -1;
// Linear Search Implementation
for (int i = 0; i < [Link]; i++) {
if (arr[i] == key) {
pos = i;
break;
}
}
if (pos!= -1) [Link]("Found at index " + pos);
else [Link]("Element not found.");
}
}
Result/Conclusion
The integration of Bubble Sort and Linear Search provides a complete workflow for data
organization and retrieval.47
30 Target: 22 Sorted: 11 12 22 25 34 64 90 \n
Found at index 2
One of the most significant insights gained from Section II (Special Numbers) is the utility of the
extracts the last digit and removes it—is the foundational mechanism for numerical
2
analysis in high-level languages. Furthermore, Section III highlights the synergy between
primitive types and objects via wrapper classes, which is a precursor to understanding
object-oriented design and Java's type system.21
The String Handling section (Section IV) emphasizes the importance of immutability and
character manipulation. The ability to reverse strings or sort words lexicographically using
compareTo() introduces the student to the complexity of non-numeric data structures.28
Finally, Section V introduces the concepts of space and time complexity through basic sorting
and searching. While Bubble Sort and Linear Search are computationally expensive (
Collectively, these programs fulfill the practical requirements of the ICSE 2026 syllabus while
fostering a disciplined approach to variable declaration, modular commenting, and algorithmic
clarity. The transition from these 30 programs to advanced Java concepts like Inheritance and
File Handling is a logical progression that will be facilitated by the solid foundation established
in this project file.1
Works cited
1. Menu-Driven Java Project for ICSE 2026 | PDF | Software | Programming
Paradigms - Scribd, accessed on May 4, 2026,
[Link]
2. Class 10 AI Practical File 2025-26 | PDF | Prime Number | Mathematics - Scribd,
accessed on May 4, 2026,
[Link]
26
3. Java Variable Description Table ICSE 10 | PDF - Scribd, accessed on May 4, 2026,
[Link]
4. ICSE Class X Java Project Guidelines | PDF | Letter Case | Prime Number - Scribd,
accessed on May 4, 2026,
[Link]
5. InfoSherwoodians by [Link] - Project, accessed on May 4, 2026,
[Link]
6. Number Program – SchoolCodeHub, accessed on May 4, 2026,
[Link]
7. Sum of Digits in Java - DEV Community, accessed on May 4, 2026,
[Link]
8. Variable Descriptions for Java Programs | PDF - Scribd, accessed on May 4, 2026,
[Link]
9. Next Prime Number display Java Program | KnowledgeBoat, accessed on May 4,
2026,
[Link]
and-check-whether-it-is-a-prime--12393456346174692
10.Java Pattern Printing Examples | PDF | Computer Programming - Scribd, accessed
on May 4, 2026, [Link]
11. Class 10 ICSE Java Pattern Programs | PDF | Computer Science - Scribd, accessed
on May 4, 2026,
[Link]
grams
12.Video 5 (BlueJ) : Printing patterns using nested loops (ICSE) - YouTube, accessed
on May 4, 2026, [Link]
13.Java Programs for Class 10 Projects | PDF - Scribd, accessed on May 4, 2026,
[Link]
14.A Complete Guide on Magic Number In Java - NxtWave, accessed on May 4,
2026, [Link]
15.Magic number - Java Programs -ISC & ICSE - [Link], accessed on May
4, 2026, [Link]
16.Magic Number in Java - Pune - Technogeeks, accessed on May 4, 2026,
[Link]
17.Pronic and Twisted Prime Checker | PDF | Integer (Computer Science) - Scribd,
accessed on May 4, 2026,
[Link]
18.Twisted Prime Number - SchoolCodeHub, accessed on May 4, 2026,
[Link]
d-prime-number/
19.Twisted Prime Program in Java - [Link], accessed on May 4, 2026,
[Link]
20.Library Classes Programs - Simply Coding, accessed on May 4, 2026,
[Link]
21.Understanding Java Wrapper Classes | PDF | Data Type | Integer (Computer
Science), accessed on May 4, 2026,
[Link]
22.Describe wrapper class methods available in Java to parse - KnowledgeBoat,
accessed on May 4, 2026,
[Link]
ailable-in-java-to-parse--563277752148849340
23.Chapter 12: Library Classes | Solutions for Class 10 ICSE Logix Kips Computer
Applications with BlueJ Java | KnowledgeBoat, accessed on May 4, 2026,
[Link]
s-java-bluej/solutions/92LgBo/library-classes
24.COMPUTER APPLICATION CLASS X LIBRARY CLASSES Answer the following
questions, accessed on May 4, 2026,
[Link]
[Link]
25.151. Reverse Words in a String - In-Depth Explanation - AlgoMonster, accessed on
May 4, 2026, [Link]
26.Reverse words in a given String in Java - GeeksforGeeks, accessed on May 4,
2026, [Link]
27.Java Program to Reverse Characters of each Word of a String | KnowledgeBoat,
accessed on May 4, 2026,
[Link]
-string-and-display-the--64623876323917390
28.Java Program to reverse words in a String - BeginnersBook, accessed on May 4,
2026,
[Link]
29.COMPUTER APPLICATION BLUEJ STRING PROGRAMS Set-2 Program1. Write a
program to accept a string. Display the new string after rev, accessed on May 4,
2026,
[Link]
[Link]
30.Reverse String Word by Word in Java - Stack Overflow, accessed on May 4, 2026,
[Link]
va
31.How to reverse words in string in java without using split and stringtokenizer
[closed], accessed on May 4, 2026,
[Link]
n-java-without-using-split-and-stringtokenizer
32.Multiple Ways to Reverse Words in a Sentence in Java. | DroidStack - Medium,
accessed on May 4, 2026,
[Link]
n-java-0cd84a217368
33.Java Program to reverse individual words in the sentence - Stack Overflow,
accessed on May 4, 2026,
[Link]
al-words-in-the-sentence
34.Sort Words Java Program | ISC Computer Science 2023 Paper 1 - Robin Sir,
accessed on May 4, 2026, [Link]
35.Using Bubble Sort to Alphabetically Sort Array of Names in Java - Stack Overflow,
accessed on May 4, 2026,
[Link]
lly-sort-array-of-names-in-java
36.Java program to perform Bubble Sort on Strings - BeginnersBook, accessed on
May 4, 2026,
[Link]
trings/
37.Java Program to Sort Names in an Alphabetical Order - GeeksforGeeks,
accessed on May 4, 2026,
[Link]
tical-order/
38.Java Program for Alphabetical Sorting | PDF | String (Computer Science) - Scribd,
accessed on May 4, 2026, [Link]
39.Java Program on Bubble Sort - Simply Coding, accessed on May 4, 2026,
[Link]
40.Sorting Text Alphabetically with Java Code - Medium, accessed on May 4, 2026,
[Link]
ode-177cfc072947
41.Program to find smallest and largest element in an array - Talent Battle, accessed
on May 4, 2026,
[Link]
-to-find-smallest-and-largest-element-in-an-array
42.Java - Finding Largest and Smallest Numbers using an Array - Stack Overflow,
accessed on May 4, 2026,
[Link]
-numbers-using-an-array
43.Largest, Smallest, and Average in Array | PDF - Scribd, accessed on May 4, 2026,
[Link]
44.Finding the Smallest and largest element in an array in Java - PrepInsta, accessed
on May 4, 2026,
[Link]
nt-in-an-array/
45.Finding the Largest and Smallest Numbers in an Array Using Java: A Simple
Step-by-Step Guide - Medium, accessed on May 4, 2026,
[Link]
array-using-java-a-simple-step-by-step-guide-c13601a98b45
46.bubble sort using methods - Java Programs -ISC & ICSE, accessed on May 4,
2026, [Link]
47.Java Program for Bubble Sort - GeeksforGeeks, accessed on May 4, 2026,
[Link]
48.Bubble Sort in Java: Functionality, Implementation & Performance | [Link],
accessed on May 4, 2026,
[Link]
[Link]
49.Java: Algorithms: Searching and Sorting Cheatsheet | Codecademy, accessed on
May 4, 2026,
[Link]
d-sorting/cheatsheet