S.R.
EDUCATION CENTRE
KANPUR, UTTAR PRADESH
COMPUTER SCIENCE PROJECT FILE
CLASS XII (ISC BOARD)
JAVA PROGRAMMING COMPEDIUM
NAME: ____________________________
CLASS: XII (Science)
ROLL NUMBER: ____________________
SUBJECT CODE: 868
INSTITUTION: S.R. Education Centre
ACADEMIC YEAR: 2025-2026
S.R. Education Centre • Computer Science Project 1
ACKNOWLEDGEMENT
I would like to express my special thanks of gratitude to my school
management and our respected Principal, as well as our Computer Science
teacher, whose guidance and constant supervision provided pivotal support
in the successful completion of this project file.
This project has given me a wonderful opportunity to enhance my technical
acumen and immerse myself deeply into advanced structural design, object-
oriented paradigms, array handling mechanisms, dynamic matrix
architectures, recursion formulations, linear data structures like Queues,
and complex string manipulations required by the Council for the Indian
School Certificate Examinations (CISCE) for Class XII Computer Science
Practical Coursework.
Lastly, I wish to extend my appreciation to my family and peers who
directly or lagooned through feedback assisted me in consolidating these
programs into a systematic, bound digital portfolio compilation.
Student's Signature: _______________
S.R. Education Centre • Computer Science Project 2
CERTIFICATE OF AUTHENTICITY
This is to certify that the Java Programming implementations submitted in
this compilation constitute an authentic record of practical work executed
by Candidate ___________________________ of Class XII, S.R. Education
Centre, Kanpur, under the supervision and curriculum guidelines specified
for the Indian School Certificate (ISC) Examination.
All programs listed within this project file have been compiled, debugged,
and verified independently inside a standard Java Virtual Machine (JVM)
environment. Satisfactory data-validation rules, algorithm formulations,
and operational output criteria have been meticulously executed.
__________________________
__________________________
Internal Examiner
External Examiner
Designation: Dept. of Computer
Date:
Science
Principal's Seal & Signature
S.R. Education Centre • Computer Science Project 3
ASSIGNMENT 1: Currency Denomination & Number to Words
Question Statement: A bank intends to design a program to display the
denomination of an input amount, up to 5 digits. The available denominations are
2000, 500, 200, 100, 50, 20, 10, and 1. Accept the amount from the user, display
its break-up in descending order of preference (highest denomination first),
compute the total number of notes, and print the amount in words digit-by-digit.
Only utilized denominations should be displayed.
Source Code (Java)
import [Link];
public class Denomination {
public static void main(String[] args) {
Scanner in = new Scanner([Link] == null ? new Scanner([Link]) : in);
[Link]("INPUT: ");
int amount = [Link]();
if (amount < 1 || amount > 99999) {
[Link]("INVALID AMOUNT (MUST BE UP TO 5 DIGITS)");
return;
}
// Convert digits to words
String amtStr = [Link](amount);
String[] words = {"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven",
"Eight", "Nine"};
[Link]("OUTPUT: ");
for (int i = 0; i < [Link](); i++) {
[Link](words[[Link](i) - '0'] + " ");
}
[Link]();
// Denomination Breakdown
int[] notes = {2000, 500, 200, 100, 50, 20, 10, 1};
int temp = amount;
int totalNotes = 0;
[Link]("Denomination:");
for (int note : notes) {
if (temp >= note) {
int count = temp / note;
[Link](note + " * " + count + " = " + (note * count));
totalNotes += count;
temp %= note;
}
}
[Link]("TOTAL NUMBER OF NOTES = " + totalNotes);
S.R. Education Centre • Computer Science Project 4
}
}
Variable Description Table
Variable Data
Description
Name Type
amount int Stores the original input currency value from user.
amtStr String String representation of the input amount to extract digits.
Constant dictionary array storing numeric digits from 0-9 in
words String[]
words.
Array containing the legal bank vault currency denominations
notes int[]
in descending order.
Temporary loop-variable to decrement during modulus
temp int
operation.
Accumulator variable tracking total count of valid currency
totalNotes int
notes.
Console Execution Output
INPUT: 14836
OUTPUT: One Four Eight Three Six
Denomination:
2000 * 7 = 14000
500 * 1 = 500
200 * 1 = 200
100 * 1 = 100
20 * 1 = 20
10 * 1 = 10
1 * 6 = 6
TOTAL NUMBER OF NOTES = 17
S.R. Education Centre • Computer Science Project 5
ASSIGNMENT 2: Class Object String - Word Sorting (SortAlpha)
Question Statement: Specify a class SortAlpha to accept a sentence in upper
case, extract the individual words, and sort them into alphabetical order.
Design constructors, member methods, object parameters, and a main container
invocation.
Source Code (Java)
import [Link];
public class SortAlpha {
String sent;
int n;
public SortAlpha() {
sent = "";
n = 0;
}
public void acceptsent() {
Scanner in = new Scanner([Link]);
[Link]("Enter Sentence in UPPER CASE: ");
sent = [Link]().trim().toUpperCase();
}
public void sort(SortAlpha P) {
String str = [Link];
// Strip out trailing punctuation for clean string tokens
if([Link](".")) str = [Link](0, [Link]()-1);
String[] words = [Link]("\s+");
this.n = [Link];
// Bubble sort on word arrays
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (words[j].compareTo(words[j + 1]) > 0) {
String temp = words[j];
words[j] = words[j + 1];
words[j + 1] = temp;
}
}
}
// Rebuild sorted sentence string back to instance level
StringBuilder sb = new StringBuilder();
for (String w : words) {
[Link](w).append(" ");
}
S.R. Education Centre • Computer Science Project 6
[Link] = [Link]().trim();
}
public void display() {
[Link]("Original Sentence: " + [Link]);
SortAlpha sortedObj = new SortAlpha();
[Link](this);
[Link]("Alphabetical Word Order: " + [Link]);
}
public static void main(String[] args) {
SortAlpha obj = new SortAlpha();
[Link]();
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
Instance variable to save current original or rearranged
sent String
sentences.
Saves total number of words dynamically discovered via
n int
tokenizer.
words String[] Array array of tokens split using regex blank spaces.
temp String Temporary placeholder value for string swapping during sort.
Console Execution Output
Enter Sentence in UPPER CASE: THE SKY IS BLUE
Original Sentence: THE SKY IS BLUE
Alphabetical Word Order: BLUE IS SKY THE
S.R. Education Centre • Computer Science Project 7
ASSIGNMENT 3: Calendar Date Processor (Convert)
Question Statement: Design a class Convert to receive a positive integer day
number (1-366) alongside a 4-digit calendar year value, transforming this
ordinal rank into standard day-of-month format and textual month name string,
taking full care of leap year variables.
Source Code (Java)
import [Link];
public class Convert {
int n, d, m, y;
public Convert() {
n = 0; d = 0; m = 0; y = 0;
}
public void accept() {
Scanner in = new Scanner([Link]);
[Link]("Enter Day Number: ");
n = [Link]();
[Link]("Enter Year: ");
y = [Link]();
}
public void day_to_date() {
int[] daysInMonth = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// Leap Year Evaluation
if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) {
daysInMonth[2] = 29;
}
int totalDays = ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) ? 366 : 365;
if(n < 1 || n > totalDays) {
[Link]("DAYS OUT OF BOUNDS FOR THE CHOSEN YEAR.");
return;
}
int temp = n;
m = 1;
while (temp > daysInMonth[m]) {
temp -= daysInMonth[m];
m++;
}
d = temp; // Remaining days maps as target date
}
public void display() {
S.R. Education Centre • Computer Science Project 8
day_to_date();
String[] monthNames = {"", "January", "February", "March", "April", "May",
"June",
"July", "August", "September", "October", "November",
"December"};
if(m >= 1 && m <= 12) {
[Link]("Corresponding Date: " + monthNames[m] + " " + d + ", " +
y);
}
}
public static void main(String[] args) {
Convert obj = new Convert();
[Link]();
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
Data members storing: raw day number, calculated date, month
n, d, m, y int
code, and target year.
Array tracking maximum date counts for individual lookup
daysInMonth int[]
columns (1-12).
monthNames String[] Dictionary literal defining text month string lookups.
Console Execution Output
Enter Day Number: 64
Enter Year: 2020
Corresponding Date: March 4, 2020
S.R. Education Centre • Computer Science Project 9
ASSIGNMENT 4: Sorted Array Recursive Binary Search
(BinSearch)
Question Statement: Design a class BinSearch containing a single dimension
structure array. Sort the structural contents inside an ascending sorting
scheme, and initiate a search pattern seeking variable item element 'v' via
exact Recursive Binary Search technique.
Source Code (Java)
import [Link];
public class BinSearch {
int[] arr;
int n;
public BinSearch(int nn) {
n = nn;
arr = new int[n];
}
public void fillarray() {
Scanner in = new Scanner([Link]);
[Link]("Enter " + n + " integers into the array:");
for (int i = 0; i < n; i++) {
arr[i] = [Link]();
}
}
public void sort() {
// Implementation using Selection Sort technique
for (int i = 0; i < n - 1; i++) {
int minIdx = i;
for (int j = i + 1; j < n; j++) {
if (arr[j] < arr[minIdx]) {
minIdx = j;
}
}
int temp = arr[minIdx];
arr[minIdx] = arr[i];
arr[i] = temp;
}
}
public int bin_search(int l, int u, int v) {
if (l > u) {
return -1;
}
int mid = l + (u - l) / 2;
S.R. Education Centre • Computer Science Project 10
if (arr[mid] == v) {
return mid;
} else if (arr[mid] > v) {
return bin_search(l, mid - 1, v);
} else {
return bin_search(mid + 1, u, v);
}
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter array limit: ");
int size = [Link]();
BinSearch obj = new BinSearch(size);
[Link]();
[Link]();
[Link]("Enter value to search: ");
int target = [Link]();
int location = obj.bin_search(0, size - 1, target);
if (location != -1) {
[Link]("ELEMENT FOUND AT INDEX LOCATION: " + location);
} else {
[Link]("ELEMENT NOT FOUND IN THE ARRAY.");
}
}
}
Variable Description Table
Variable Data
Description
Name Type
One-dimensional integer array holding primary collection
arr[] int[]
members.
Tracks structural sizing constraints declared during object
n int
initiation.
Input parameters matching current lower limit, upper limit
l, u, v int
bounds, and active query value.
mid int Calculated internal midpoint split position.
S.R. Education Centre • Computer Science Project 11
Console Execution Output
Enter array limit: 5
Enter 5 integers into the array:
45 12 89 23 67
Enter value to search: 67
ELEMENT FOUND AT INDEX LOCATION: 3
S.R. Education Centre • Computer Science Project 12
ASSIGNMENT 5: 2D Matrix Transposition Modality (Trans)
Question Statement: Build a framework to define an m x m square matrix class
'Trans'. Produce the matrix transposition sequence by dynamically swapping data
bounds across cell row-column locations.
Source Code (Java)
import [Link];
public class Trans {
int[][] arr;
int m;
public Trans(int mm) {
m = mm;
arr = new int[m][m];
}
public void fillarray() {
Scanner in = new Scanner([Link]);
[Link]("Enter matrix elements row-wise (" + m + "x" + m + "):");
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
arr[i][j] = [Link]();
}
}
}
public void transpose() {
int[][] transposed = new int[m][m];
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
transposed[j][i] = arr[i][j];
}
}
[Link] = transposed;
}
public void display() {
[Link]("ORIGINAL MATRIX:");
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
[Link](arr[i][j] + " ");
}
[Link]();
}
transpose();
S.R. Education Centre • Computer Science Project 13
[Link]("TRANSPOSE MATRIX:");
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
[Link](arr[i][j] + " ");
}
[Link]();
}
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter size of square matrix: ");
int size = [Link]();
Trans obj = new Trans(size);
[Link]();
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
Two dimensional storage matrix containing numerical cell
arr[][] int[][]
bounds.
m int Dimension sizing indicating absolute grid dimensions.
Local buffer matrix generated during index transposition
transposed int[][]
mapping.
Console Execution Output
Enter size of square matrix: 3
Enter matrix elements row-wise (3x3):
1 2 3
4 5 6
7 8 9
ORIGINAL MATRIX:
1 2 3
4 5 6
7 8 9
TRANSPOSE MATRIX:
1 4 7
2 5 8
3 6 9
S.R. Education Centre • Computer Science Project 14
ASSIGNMENT 6: Mathematical Happy Number Verifier
Question Statement: Check whether an explicit number is a Happy Number. A number
loops into happiness if replacement by sum-of-squares of constituent digits
repeatedly targets terminal index 1.
Source Code (Java)
import [Link];
public class HappyNumber {
public static int getSquareSum(int num) {
int sum = 0;
while (num > 0) {
int digit = num % 10;
sum += (digit * digit);
num /= 10;
}
return sum;
}
public static boolean isHappy(int n) {
int slow = n, fast = n;
// Cycle detection mechanism utilizing Floyd's algorithm
do {
slow = getSquareSum(slow);
fast = getSquareSum(getSquareSum(fast));
} while (slow != fast);
return (slow == 1);
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Input n = ");
int n = [Link]();
if (isHappy(n)) {
[Link]("Output: True
" + n + " is a Happy Number.");
} else {
[Link]("Output: False
" + n + " is not a Happy Number.");
}
}
}
S.R. Education Centre • Computer Science Project 15
Variable Description Table
Variable Name Data Type Description
n int Input raw data variable.
slow, fast int Pointers executing cycle evaluation criteria.
sum, digit int Intermediate summation buffers tracking isolated values.
Console Execution Output
Input n = 19
Output: True
19 is a Happy Number.
S.R. Education Centre • Computer Science Project 16
ASSIGNMENT 7: Fibonacci Sequence Generator Progression
Question Statement: Formulate an interactive functional model printing N-th
terms associated with the standard Fibonacci sequence model structure starting
from base limits 0 and 1.
Source Code (Java)
import [Link];
public class Fibonacci {
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Input: N = ");
int n = [Link]();
if (n <= 0) {
[Link]("Please enter a positive limit.");
return;
}
int first = 0, second = 1;
[Link]("Output: ");
for (int i = 1; i <= n; i++) {
[Link](first + " ");
int next = first + second;
first = second;
second = next;
}
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
n int Max limits declared for processing sequence length.
first, Base track variables matching leading sequence historical
int
second pairs.
next int Computed running value derived by cumulative pairing sums.
S.R. Education Centre • Computer Science Project 17
Console Execution Output
Input: N = 10
Output: 0 1 1 2 3 5 8 13 21 34
S.R. Education Centre • Computer Science Project 18
ASSIGNMENT 8: Class Inheritance - Employee Remuneration
Hierarchy
Question Statement: Define a derived subclass structure 'Overtime' expanding
upon properties of superclass 'EmpSal'. Compute supplementary salary adjustments
evaluating extra-hour performance bands via hierarchy mappings.
Source Code (Java)
class EmpSal {
protected String empnum; // Storing employee name string
protected int empcode;
protected double salary;
public EmpSal(String name, int code, double sal) {
empnum = name;
empcode = code;
salary = sal;
}
public void show() {
[Link]("Employee Code: " + empcode);
[Link]("Employee Name: " + empnum);
[Link]("Base Salary: Rs. " + salary);
}
}
public class Overtime extends EmpSal {
int hours;
double totsal;
public Overtime(String name, int code, double sal, int hrs) {
super(name, code, sal);
[Link] = hrs;
[Link] = 0.0;
}
public void calSal() {
double overtimePremium = 0.0;
if (hours > 40) {
overtimePremium = 5000.0;
} else if (hours >= 30) {
overtimePremium = 3000.0;
} else {
overtimePremium = 0.0;
}
totsal = salary + overtimePremium;
}
S.R. Education Centre • Computer Science Project 19
@Override
public void show() {
[Link]();
calSal();
[Link]("Overtime Work Hours: " + hours);
[Link]("Calculated Total Salary: Rs. " + totsal);
}
public static void main(String[] args) {
Overtime emp = new Overtime("John Doe", 1024, 45000.50, 35);
[Link]("--- EMPLOYEE OVERTIME REPORT ---");
[Link]();
}
}
Variable Description Table
Variable
Data Type Description
Name
empnum String Superclass attribute storing full target name labels.
empcode, int, Employee identification primary index keys and fractional
salary double currency base bounds.
hours, int, Subclass properties preserving overtime duration metrics and
totsal double structural aggregates.
Console Execution Output
--- EMPLOYEE OVERTIME REPORT ---
Employee Code: 1024
Employee Name: John Doe
Base Salary: Rs. 45000.5
Overtime Work Hours: 35
Calculated Total Salary: Rs. 48000.5
S.R. Education Centre • Computer Science Project 20
ASSIGNMENT 9: Perfect Cube Digit Validation - Dudeney Number
Question Statement: Process integers to locate valid Dudeney Numbers. A value
meets criteria when it matches a perfect cube integer and its sum of digits
equals its calculated cube root.
Source Code (Java)
import [Link];
public class Dudeney {
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter a positive number: ");
int n = [Link]();
// Compute integer rounded cube root estimation
int cRoot = (int) [Link]([Link](n));
// Confirm condition match validation
if (cRoot * cRoot * cRoot != n) {
[Link](n + " IS NOT A DUDENEY NUMBER (Not a perfect cube).");
return;
}
int temp = n;
int digitSum = 0;
while (temp > 0) {
digitSum += (temp % 10);
temp /= 10;
}
[Link]("Sum of digits = " + digitSum);
[Link]("Cube root of " + n + " = " + cRoot);
if (digitSum == cRoot) {
[Link]("Hence, " + n + " is a Dudeney number.");
} else {
[Link]("Hence, " + n + " is NOT a Dudeney number.");
}
}
}
S.R. Education Centre • Computer Science Project 21
Variable Description Table
Variable Name Data Type Description
n int Input raw values intended for examination.
cRoot int Evaluated cube root transformation value.
digitSum int Summation accumulator loop variable.
Console Execution Output
Enter a positive number: 512
Sum of digits = 8
Cube root of 512 = 8
Hence, 512 is a Dudeney number.
S.R. Education Centre • Computer Science Project 22
ASSIGNMENT 10: Character Interleaving Machine (Mix)
Question Statement: Define a system class 'Mix' that processes a pair of custom
words, concatenating character blocks sequentially. If length sets vary,
appending remaining trailing blocks behind execution ranges.
Source Code (Java)
import [Link];
public class Mix {
String wrd;
int len;
public Mix() {
wrd = "";
len = 0;
}
public void feedword() {
Scanner in = new Scanner([Link]);
[Link]("Enter Word (UPPER CASE): ");
wrd = [Link]().toUpperCase();
len = [Link]();
}
public void mix_word(Mix P, Mix Q) {
StringBuilder sb = new StringBuilder();
int pLen = [Link]();
int qLen = [Link]();
int maxLen = [Link](pLen, qLen);
for (int i = 0; i < maxLen; i++) {
if (i < pLen) {
[Link]([Link](i));
}
if (i < qLen) {
[Link]([Link](i));
}
}
[Link] = [Link]();
[Link] = [Link]();
}
public void display() {
[Link]("Resultant Interleaved Word: " + wrd);
}
public static void main(String[] args) {
Mix objP = new Mix();
S.R. Education Centre • Computer Science Project 23
Mix objQ = new Mix();
[Link]("For Object P:");
[Link]();
[Link]("For Object Q:");
[Link]();
Mix result = new Mix();
result.mix_word(objP, objQ);
[Link]();
}
}
Variable Description Table
Variable
Data Type Description
Name
wrd String Preserves dynamic internal character arrays.
len int Character length tracker.
Volatile operational frame holding intermediate appended
sb StringBuilder
components.
Console Execution Output
For Object P:
Enter Word (UPPER CASE): JUMP
For Object Q:
Enter Word (UPPER CASE): STROLL
Resultant Interleaved Word: JSUTMRPOLL
S.R. Education Centre • Computer Science Project 24
ASSIGNMENT 11: Circular Queue Ring Buffer (CirQueue)
Question Statement: Build abstract methods execution bounds handling array
structures styled as circular queue rings based on modular mathematical
increments. Implement push() and pop() handling limits.
Source Code (Java)
public class CirQueue {
int[] cq;
int cap;
int front;
int rear;
int count; // Helper to distinctly recognize layout bounds
public CirQueue(int max) {
cap = max;
cq = new int[cap];
front = 0;
rear = 0;
count = 0;
}
public void push(int n) {
if (count == cap) {
[Link]("QUEUE IS FULL");
return;
}
cq[rear] = n;
rear = (rear + 1) % cap;
count++;
}
public int pop() {
if (count == 0) {
return -9999;
}
int item = cq[front];
front = (front + 1) % cap;
count--;
return item;
}
public void show() {
if (count == 0) {
[Link]("Queue is empty.");
return;
}
[Link]("Queue Elements: ");
int idx = front;
S.R. Education Centre • Computer Science Project 25
for (int i = 0; i < count; i++) {
[Link](cq[idx] + " ");
idx = (idx + 1) % cap;
}
[Link]();
}
public static void main(String[] args) {
CirQueue q = new CirQueue(4);
[Link]("--- Executing Circular Queue Modality ---");
[Link](10);
[Link](20);
[Link](30);
[Link]();
[Link]("Popped item: " + [Link]());
[Link](40);
[Link](50);
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
cq[] int[] Primary storage array buffer mapping cyclic space indices.
Capacity constraint bounds and tracking elements currently
cap, count int
residing inside memory.
front, rear int Circular pointers tracking data removals and insertions.
Console Execution Output
--- Executing Circular Queue Modality ---
Queue Elements: 10 20 30
Popped item: 10
Queue Elements: 20 30 40 50
S.R. Education Centre • Computer Science Project 26
ASSIGNMENT 12: Recursive Armstrong Identity Tracker (ArmNum)
Question Statement: Check if a target integer number configuration is Armstrong
by building a recursive calculation method sum_pow(). Elements conform when
numerical sums raised to overall dimension sizes evaluate back to matching self-
containment parameters.
Source Code (Java)
import [Link];
public class ArmNum {
int n;
int l;
public ArmNum(int nn) {
n = nn;
l = [Link](n).length();
}
public int sum_pow(int i) {
if (i == 0) {
return 0;
}
int digit = i % 10;
return (int) [Link](digit, l) + sum_pow(i / 10);
}
public void isArmstrong() {
int resultSum = sum_pow(n);
if (resultSum == n) {
[Link](n + " IS AN ARMSTRONG NUMBER.");
} else {
[Link](n + " IS NOT AN ARMSTRONG NUMBER.");
}
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter integer value to verify: ");
int inputVal = [Link]();
ArmNum obj = new ArmNum(inputVal);
[Link]();
}
}
S.R. Education Centre • Computer Science Project 27
Variable Description Table
Variable Data
Description
Name Type
n, l int Preserves identity assessment boundaries and sequence length.
Tracks isolated remainder cells separated during calculation
digit int
steps.
Console Execution Output
Enter integer value to verify: 1634
1634 IS AN ARMSTRONG NUMBER.
S.R. Education Centre • Computer Science Project 28
ASSIGNMENT 13: 2D Matrix Grid Digit Reversal (MatRev)
Question Statement: Populate an m x n multi-dimensional storage array using
class 'MatRev'. Provide member methods executing individual numerical data
reversals before reconstructing them into target array cells.
Source Code (Java)
import [Link];
public class MatRev {
int[][] arr;
int m, n;
public MatRev(int mm, int nn) {
m = mm;
n = nn;
arr = new int[m][n];
}
public void fillarray() {
Scanner in = new Scanner([Link]);
[Link]("Enter matrix elements (" + m + "x" + n + "):");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
arr[i][j] = [Link]();
}
}
}
public int reverse(int x) {
int rev = 0;
while (x > 0) {
rev = (rev * 10) + (x % 10);
x /= 10;
}
return rev;
}
public void revMat(MatRev P) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
[Link][i][j] = reverse([Link][i][j]);
}
}
}
public void show() {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
S.R. Education Centre • Computer Science Project 29
[Link](arr[i][j] + " ");
}
[Link]();
}
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter Rows (m): ");
int r = [Link]();
[Link]("Enter Columns (n): ");
int c = [Link]();
MatRev inputObj = new MatRev(r, c);
[Link]();
MatRev outputObj = new MatRev(r, c);
[Link](inputObj);
[Link]("PROCESSED DIGIT REVERSED MATRIX:");
[Link]();
}
}
Variable Description Table
Variable Name Data Type Description
arr[][] int[][] Two dimensional storage grid.
m, n int Row and Column constraints.
rev int Accumulation step reference variable.
Console Execution Output
Enter Rows (m): 2
Enter Columns (n): 2
Enter matrix elements (2x2):
12 34
56 78
PROCESSED DIGIT REVERSED MATRIX:
21 43
65 87
S.R. Education Centre • Computer Science Project 30
ASSIGNMENT 14: Recursive Perfect Factor Inspector (Perfect)
Question Statement: Build class 'Perfect' to assess if an argument satisfies
mathematical perfection rules. A number is perfect when the sum of its divisors,
excluding the number itself, perfectly evaluates to the number's initial state.
Use a recursive approach.
Source Code (Java)
import [Link];
public class Perfect {
int num;
public Perfect(int nn) {
num = nn;
}
public int sum_of_factors(int i) {
// Base case terminating search
if (i == 1) {
return 1;
}
if (num % i == 0) {
return i + sum_of_factors(i - 1);
} else {
return sum_of_factors(i - 1);
}
}
public void check() {
if(num <= 1) {
[Link](num + " IS NOT A PERFECT NUMBER.");
return;
}
// Initialize factor exploration beginning at num/2 down to 1
int sum = sum_of_factors(num / 2);
if (sum == num) {
[Link](num + " IS A PERFECT NUMBER.");
} else {
[Link](num + " IS NOT A PERFECT NUMBER.");
}
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter structural evaluation value: ");
int inputVal = [Link]();
Perfect obj = new Perfect(inputVal);
S.R. Education Centre • Computer Science Project 31
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
num int Saves integer properties chosen for testing.
Recursive parameter executing current index calculation
i int
steps.
sum int Preserves accumulated returned values.
Console Execution Output
Enter structural evaluation value: 6
6 IS A PERFECT NUMBER.
S.R. Education Centre • Computer Science Project 32
ASSIGNMENT 15: Initial Character Capital Tracker (Capital)
Question Statement: Define structural classes named 'Capital' tracking string
expressions to find word elements that begin with an uppercase alphabet letter.
Source Code (Java)
import [Link];
public class Capital {
String sent;
int freq;
public Capital() {
sent = "";
freq = 0;
}
public void input() {
Scanner in = new Scanner([Link]);
[Link]("Enter Sentence: ");
sent = [Link]().trim();
}
public boolean isCap(String w) {
if (w == null || [Link]()) return false;
char ch = [Link](0);
return (ch >= 'A' && ch <= 'Z');
}
public void display() {
freq = 0;
// Split text parsing punctuation limits out safely
String[] words = [Link]("\s+");
for (String word : words) {
// Remove lingering final periods or symbols if present
String cleanWord = [Link]("[^a-zA-Z]", "");
if (isCap(cleanWord)) {
freq++;
}
}
[Link]("Sentence: " + sent);
[Link]("Frequency of Capitalized words: " + freq);
}
public static void main(String[] args) {
Capital obj = new Capital();
[Link]();
[Link]();
S.R. Education Centre • Computer Science Project 33
}
}
Variable Description Table
Variable Data
Description
Name Type
sent String Saves original line input sentences.
freq int Total accumulator increment.
Processed clean sub-word strings isolated for index
cleanWord String
inspections.
Console Execution Output
Enter Sentence: The Red car is driving in Kanpur city.
Sentence: The Red car is driving in Kanpur city.
Frequency of Capitalized words: 3
S.R. Education Centre • Computer Science Project 34
ASSIGNMENT 16: Factorial Series Base Hierarchy Expansion
(Series)
Question Statement: Specify a superclass 'Number' which defines base factorials.
Derive a secondary class 'Series' tracking mathematical sum sequences
represented by S = 1! + 2! + 3! + ... + n!.
Source Code (Java)
class Number {
protected int n;
public Number(int nn) {
n = nn;
}
public int factorial(int a) {
int fact = 1;
for (int i = 1; i <= a; i++) {
fact *= i;
}
return fact;
}
public void display() {
[Link]("Upper Range Limit (n) = " + n);
}
}
public class Series extends Number {
int sum;
public Series(int nn) {
super(nn);
sum = 0;
}
public void calsum() {
sum = 0;
for (int i = 1; i <= n; i++) {
sum += factorial(i);
}
}
@Override
public void display() {
[Link]();
calsum();
[Link]("Calculated Accumulative Factorial Series Sum = " + sum);
S.R. Education Centre • Computer Science Project 35
}
public static void main(String[] args) {
Series obj = new Series(4);
[Link]("--- FACTORIAL SERIES PROGRESSION ---");
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
n int Upper bound limits shared down from higher components.
Internal accumulator for computing individual factorial
fact int
components.
sum int Preserves dynamic mathematical calculations totals.
Console Execution Output
--- FACTORIAL SERIES PROGRESSION ---
Upper Range Limit (n) = 4
Calculated Accumulative Factorial Series Sum = 33
S.R. Education Centre • Computer Science Project 36
ASSIGNMENT 17: Recursive Palindrome Value Verification
(Palin)
Question Statement: Model class 'Palin' to check for numerical palindrome
identity using a recursive logic process to extract and match value mirrors.
Source Code (Java)
import [Link];
public class Palin {
int num;
int revnum;
public Palin() {
num = 0;
revnum = 0;
}
public void accept() {
Scanner in = new Scanner([Link]);
[Link]("Enter positive number to test: ");
num = [Link]();
}
public int reverse(int y, int currentRev) {
if (y == 0) {
return currentRev;
}
return reverse(y / 10, (currentRev * 10) + (y % 10));
}
public void check() {
revnum = reverse(num, 0);
[Link]("Original Number: " + num);
[Link]("Reversed Number: " + revnum);
if (num == revnum) {
[Link]("RESULT: TYPE IS A VALID PALINDROME.");
} else {
[Link]("RESULT: TYPE IS NOT A PALINDROME.");
}
}
public static void main(String[] args) {
Palin obj = new Palin();
[Link]();
[Link]();
}
}
S.R. Education Centre • Computer Science Project 37
Variable Description Table
Variable Data
Description
Name Type
num, revnum int Original integers and inverted numerical structures.
y, Recursive working parameters tracking base remnants and digit
int
currentRev positioning adjustments.
Console Execution Output
Enter positive number to test: 121
Original Number: 121
Reversed Number: 121
RESULT: TYPE IS A VALID PALINDROME.
S.R. Education Centre • Computer Science Project 38
ASSIGNMENT 18: String Character Permutation (SwapSort)
Question Statement: Class 'SwapSort' parses specific uppercase word sets.
Interchange flanking character positions, and then apply an alphabetical sorting
process across the original string data structures.
Source Code (Java)
import [Link];
import [Link];
public class SwapSort {
String wrd;
int len;
String swapwrd;
String sortwrd;
public SwapSort() {
wrd = ""; len = 0; swapwrd = ""; sortwrd = "";
}
public void readword() {
Scanner in = new Scanner([Link]);
[Link]("Enter single word in UPPER CASE: ");
wrd = [Link]().toUpperCase();
len = [Link]();
}
public void swapchar() {
if (len <= 1) {
swapwrd = wrd;
return;
}
char first = [Link](0);
char last = [Link](len - 1);
swapwrd = last + [Link](1, len - 1) + first;
}
public void sortword() {
char[] chars = [Link]();
[Link](chars);
sortwrd = new String(chars);
}
public void display() {
swapchar();
sortword();
[Link]("Original Word : " + wrd);
[Link]("Swapped Word : " + swapwrd);
[Link]("Sorted Word : " + sortwrd);
S.R. Education Centre • Computer Science Project 39
}
public static void main(String[] args) {
SwapSort obj = new SwapSort();
[Link]();
[Link]();
}
}
Variable Description Table
Data
Variable Name Description
Type
wrd, swapwrd, Stores the original, swapped, and sorted string
String
sortwrd variations.
len int Text length measure container.
Intermediate array holding individual elements for
chars char[]
sorting operations.
Console Execution Output
Enter single word in UPPER CASE: BRAVO
Original Word : BRAVO
Swapped Word : ORAVB
Sorted Word : ABORV
S.R. Education Centre • Computer Science Project 40
ASSIGNMENT 19: Linear Integer Queue Data Structure (Queue)
Question Statement: Build a standard bounded FIFO linear data structure queue
using class 'Queue'. Maintain appropriate indices to manage Overflow and
Underflow conditions.
Source Code (Java)
public class Queue {
int[] Que;
int size;
int front;
int rear;
public Queue(int mm) {
size = mm;
Que = new int[size];
front = 0;
rear = 0;
}
public void addele(int v) {
if (rear == size) {
[Link]("Overflow");
return;
}
Que[rear++] = v;
}
public int delele() {
if (front == rear) {
[Link]("Underflow");
return -9999;
}
return Que[front++];
}
public void display() {
if (front == rear) {
[Link]("Queue is Empty.");
return;
}
[Link]("Queue Content Elements: ");
for (int i = front; i < rear; i++) {
[Link](Que[i] + " ");
}
[Link]();
}
public static void main(String[] args) {
S.R. Education Centre • Computer Science Project 41
Queue q = new Queue(3);
[Link]("--- PROCESSING STANDARD LINEAR QUEUE ---");
[Link](105);
[Link](210);
[Link]();
[Link]("Removed element: " + [Link]());
[Link]();
}
}
Variable Description Table
Variable Name Data Type Description
Que[] int[] Primary integer storage structure array.
size int The maximum allocation capacity threshold.
front, rear int Tracking pointers managing deletions and insertions.
Console Execution Output
--- PROCESSING STANDARD LINEAR QUEUE ---
Queue Content Elements: 105 210
Removed element: 105
Queue Content Elements: 210
S.R. Education Centre • Computer Science Project 42
ASSIGNMENT 20: Positional Exponential Sum - Disarium Number
Question Statement: Check if a target integer value is a Disarium Number. An
item is a Disarium number if computing the digits raised to their respective
sequential index position numbers matches the original value. Use a recursive
helper method.
Source Code (Java)
import [Link];
public class Disarium {
int num;
int size;
public Disarium(int nn) {
num = nn;
size = 0;
}
public void countDigit() {
size = [Link](num).length();
}
public int sumofDigits(int n, int p) {
if (n == 0) {
return 0;
}
int digit = n % 10;
return (int) [Link](digit, p) + sumofDigits(n / 10, p - 1);
}
public void check() {
countDigit();
// The recursive calculation begins with the last digit at position 'size'
int calcSum = sumofDigits(num, size);
if (calcSum == num) {
[Link](num + " IS A DISARIUM NUMBER.");
} else {
[Link](num + " IS NOT A DISARIUM NUMBER.");
}
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter integer property value: ");
int inputVal = [Link]();
Disarium obj = new Disarium(inputVal);
[Link]();
S.R. Education Centre • Computer Science Project 43
}
}
Variable Description Table
Variable Data
Description
Name Type
Preserves structural content target values and length
num, size int
properties.
Recursive data tracking parameters matching remaining numbers
n, p int
and index values.
Console Execution Output
Enter integer property value: 135
135 IS A DISARIUM NUMBER.
S.R. Education Centre • Computer Science Project 44
ASSIGNMENT 21: LIFO Stack Shelf Management Model (Book)
Question Statement: Specify data structure allocations tracking a LIFO inventory
collection model using class 'Book'. Implement functions void tell() and void
add(String v) according to specification rules.
Source Code (Java)
import [Link];
public class Book {
String[] name;
int point;
int max;
public Book(int cap) {
max = cap;
name = new String[max];
point = -1;
}
public void add(String v) {
if (point == max - 1) {
[Link]("SHELF FULL");
return;
}
name[++point] = v;
}
public void tell() {
if (point == -1) {
[Link]("SHELF EMPTY");
return;
}
[Link]("Last entered book element: " + name[point]);
}
public void display() {
if (point == -1) {
[Link]("Shelf has no elements.");
return;
}
[Link]("Available Inventory Collection Stack: ");
for (int i = 0; i <= point; i++) {
[Link]("[" + name[i] + "] ");
}
[Link]();
}
public static void main(String[] args) {
S.R. Education Centre • Computer Science Project 45
Book shelf = new Book(3);
[Link]("--- PROCESSING LIFO BOOK SHELF MANAGEMENT ---");
[Link]("Java Reference");
[Link]("Data Structures");
[Link]();
[Link]();
}
}
Variable Description Table
Variable Name Data Type Description
name[] String[] Storage structure tracking string data items.
point int Index tracking indicator managing the top of the stack.
max int Capacity boundary condition limit.
Console Execution Output
--- PROCESSING LIFO BOOK SHELF MANAGEMENT ---
Available Inventory Collection Stack: [Java Reference] [Data Structures]
Last entered book element: Data Structures
S.R. Education Centre • Computer Science Project 46
ASSIGNMENT 22: Numeric Concatenation Processor (Merger)
Question Statement: Design class 'Merger' to accept two long integers, link
their numerical positions, and create a single combined output value.
Source Code (Java)
import [Link];
public class Merger {
long n1;
long n2;
long mergNum;
public Merger() {
n1 = 0; n2 = 0; mergNum = 0;
}
public void readNum() {
Scanner in = new Scanner([Link]);
[Link]("Enter first positive number (n1): ");
n1 = [Link]();
[Link]("Enter second positive number (n2): ");
n2 = [Link]();
}
public void joinNum() {
String s1 = [Link](n1);
String s2 = [Link](n2);
mergNum = [Link](s1 + s2);
}
public void show() {
[Link]("Original Number 1: " + n1);
[Link]("Original Number 2: " + n2);
[Link]("Merged Concatenated Number: " + mergNum);
}
public static void main(String[] args) {
Merger obj = new Merger();
[Link]();
[Link]();
[Link]();
}
}
S.R. Education Centre • Computer Science Project 47
Variable Description Table
Variable Name Data Type Description
n1, n2 long Data attributes preserving target values.
mergNum long Merged concatenated output container.
Console Execution Output
Enter first positive number (n1): 23
Enter second positive number (n2): 764
Original Number 1: 23
Original Number 2: 764
Merged Concatenated Number: 23764
S.R. Education Centre • Computer Science Project 48
ASSIGNMENT 23: Textual Token Metric Engine (TheString)
Question Statement: Design a system class named 'TheString' to parse string
inputs. Analyze the data contents to calculate totals for words and consonants.
Source Code (Java)
import [Link];
public class TheString {
String str;
int len;
int wordCount;
int cons;
public TheString() {
str = ""; len = 0; wordCount = 0; cons = 0;
}
public TheString(String ds) {
str = ds;
len = [Link]();
}
public void countFreq() {
if (str == null || [Link]().isEmpty()) {
wordCount = 0; cons = 0; return;
}
// Parse word tokens based on spacing boundaries
String[] words = [Link]().split("\s+");
wordCount = [Link];
cons = 0;
String lower = [Link]();
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if (ch >= 'a' && ch <= 'z') {
if (ch != 'a' && ch != 'e' && ch != 'i' && ch != 'o' && ch != 'u') {
cons++;
}
}
}
}
public void display() {
countFreq();
[Link]("Original String: " + str);
[Link]("Number of Words: " + wordCount);
[Link]("Number of Consonants: " + cons);
S.R. Education Centre • Computer Science Project 49
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter Target String Expression: ");
String line = [Link]();
TheString obj = new TheString(line);
[Link]();
}
}
Variable Description Table
Data
Variable Name Description
Type
str String Saves character data array targets.
wordCount, Tracks calculation metrics for total word tokens and
int
cons consonant letters.
Console Execution Output
Enter Target String Expression: COMPUTER SCIENCE IS FUN
Original String: COMPUTER SCIENCE IS FUN
Number of Words: 4
Number of Consonants: 12
S.R. Education Centre • Computer Science Project 50
ASSIGNMENT 24: Bidirectional Prime Check - Emirp Number
Question Statement: Define class 'Emirp' to check whether a value configuration
matches Emirp number criteria. An integer is an Emirp number if it remains prime
both in its original form and when its digits are reversed. Use a recursive
helper method.
Source Code (Java)
import [Link];
public class Emirp {
int n;
int rev;
int f;
public Emirp(int nn) {
n = nn;
rev = 0;
f = 2;
}
public int isprime(int x, int divisor) {
if (x <= 1) return 0;
if (divisor * divisor > x) return 1;
if (x % divisor == 0) return 0;
return isprime(x, divisor + 1);
}
public void isEmirp() {
int temp = n;
rev = 0;
while (temp > 0) {
rev = (rev * 10) + (temp % 10);
temp /= 10;
}
int prime1 = isprime(n, 2);
int prime2 = isprime(rev, 2);
[Link]("Original Number: " + n + " (Prime Status: " +
(prime1==1?"Yes":"No") + ")");
[Link]("Reversed Number: " + rev + " (Prime Status: " +
(prime2==1?"Yes":"No") + ")");
if (prime1 == 1 && prime2 == 1 && n != rev) {
[Link](n + " IS AN EMIRP NUMBER.");
} else {
[Link](n + " IS NOT AN EMIRP NUMBER.");
}
S.R. Education Centre • Computer Science Project 51
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter value to test: ");
int val = [Link]();
Emirp obj = new Emirp(val);
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
Tracks original inputs, computed data reversals, and base
n, rev, f int
divisor loops.
prime1,
int Status indicators checking validity properties.
prime2
Console Execution Output
Enter value to test: 13
Original Number: 13 (Prime Status: Yes)
Reversed Number: 31 (Prime Status: Yes)
13 IS AN EMIRP NUMBER.
S.R. Education Centre • Computer Science Project 52
ASSIGNMENT 25: Leading Vowel Word Tracker (VowelWord)
Question Statement: Design a system class 'VowelWord' that parses sentence
strings. Analyze word elements to count how many individual tokens begin with a
vowel character.
Source Code (Java)
import [Link];
public class VowelWord {
String str;
int freq;
public VowelWord() {
str = ""; freq = 0;
}
public void readstr() {
Scanner in = new Scanner([Link]);
[Link]("Enter Sentence (terminated by a full stop): ");
str = [Link]().trim();
}
public void freq_vowel() {
freq = 0;
String workingStr = str;
if ([Link](".")) {
workingStr = [Link](0, [Link]() - 1);
}
String[] words = [Link]("\s+");
for (String w : words) {
if (![Link]()) {
char first = [Link]([Link](0));
if (first == 'a' || first == 'e' || first == 'i' || first == 'o' || first
== 'u') {
freq++;
}
}
}
}
public void display() {
freq_vowel();
[Link]("Original String: " + str);
[Link]("Frequency of words beginning with a vowel: " + freq);
}
public static void main(String[] args) {
S.R. Education Centre • Computer Science Project 53
VowelWord obj = new VowelWord();
[Link]();
[Link]();
}
}
Variable Description Table
Variable Data
Description
Name Type
str String Saves raw target line records.
freq int Total calculation count tracker.
Tracks leading character indices separated during
first char
evaluation.
Console Execution Output
Enter Sentence (terminated by a full stop): AN APPLE A DAY KEEPS THE DOCTOR AWAY.
Original String: AN APPLE A DAY KEEPS THE DOCTOR AWAY.
Frequency of words beginning with a vowel: 4
S.R. Education Centre • Computer Science Project 54
ASSIGNMENT 26: Recursive Decimal to Octal Radix Converter
(DeciOct)
Question Statement: Build class 'DeciOct' to process positive base-10 integer
numbers, converting them into matching base-8 octal values using a recursive
logic algorithm.
Source Code (Java)
import [Link];
public class DeciOct {
int n;
int oct;
public DeciOct() {
n = 0; oct = 0;
}
public void getnum(int nn) {
n = nn;
}
public int findOctal(int decimal) {
if (decimal == 0) {
return 0;
}
return (decimal % 8) + 10 * findOctal(decimal / 8);
}
public void deci_oct() {
oct = findOctal(n);
}
public void show() {
deci_oct();
[Link]("Decimal Base-10 Number: " + n);
[Link]("Octal Base-8 Conversion: " + oct);
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter Decimal Number: ");
int num = [Link]();
DeciOct obj = new DeciOct();
[Link](num);
[Link]();
S.R. Education Centre • Computer Science Project 55
}
}
Variable Description Table
Variable Data
Description
Name Type
Preserves active decimal data metrics and calculated base-8
n, oct int
output values.
decimal int Recursive parameter processing execution stacks.
Console Execution Output
Enter Decimal Number: 68
Decimal Base-10 Number: 68
Octal Base-8 Conversion: 104
S.R. Education Centre • Computer Science Project 56
ASSIGNMENT 27: Specific Sub-String Content Counter
(Frequency)
Question Statement: Implement class 'Frequency' to receive textual sentences.
Parse individual word structures to measure exact match frequencies for sub-
strings "an" and "and".
Source Code (Java)
import [Link];
public class Frequency {
String text;
int countand;
int countan;
int len;
public Frequency() {
text = ""; countand = 0; countan = 0; len = 0;
}
public void accept(String n) {
text = [Link]();
len = [Link]();
}
public void checkandfreq() {
countand = 0;
// Safeguard boundary patterns cleaning out punctuation marks
String clean = [Link]("[^a-z\s]", " ");
String[] words = [Link]("\s+");
for (String w : words) {
if ([Link]("and")) {
countand++;
}
}
}
public void checkanfreq() {
countan = 0;
String clean = [Link]("[^a-z\s]", " ");
String[] words = [Link]("\s+");
for (String w : words) {
if ([Link]("an")) {
countan++;
}
}
}
S.R. Education Centre • Computer Science Project 57
public void display() {
checkandfreq();
checkanfreq();
[Link]("Processed Text: " + text);
[Link]("Frequency of 'and': " + countand);
[Link]("Frequency of 'an' : " + countan);
}
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter sentence string: ");
String line = [Link]();
Frequency obj = new Frequency();
[Link](line);
[Link]();
}
}
Variable Description Table
Variable Name Data Type Description
text String Saves lowercase text data sets.
countand, countan int Accumulator metrics tracking sub-word tokens.
len int Character length metric indicator.
Console Execution Output
Enter sentence string: An apple and an orange, and some grapes.
Processed Text: an apple and an orange, and some grapes.
Frequency of 'and': 2
Frequency of 'an' : 2
S.R. Education Centre • Computer Science Project 58
ASSIGNMENT 28: 2D Matrix Matrix Grid Row-Column Summation
Question Statement: Populate a fixed 4x3 multi-dimensional integer structure
array, calculating sum metrics for individual structural column paths and rows.
Source Code (Java)
import [Link];
public class MatrixSum {
public static void main(String[] args) {
Scanner in = new Scanner([Link] == null ? new Scanner([Link]) : in);
int[][] matrix = new int[4][3];
[Link]("Enter matrix elements for 4x3 grid:");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
matrix[i][j] = [Link]();
}
}
[Link]("
MATRIX WITH ROW SUMS:");
// Compute and print rows sums
for (int i = 0; i < 4; i++) {
int rowSum = 0;
for (int j = 0; j < 3; j++) {
[Link](matrix[i][j] + " ");
rowSum += matrix[i][j];
}
[Link]("| Sum = " + rowSum);
}
[Link]("------------------------------------");
// Compute and print columns sums
[Link]("Col Sum: ");
for (int j = 0; j < 3; j++) {
int colSum = 0;
for (int i = 0; i < 4; i++) {
colSum += matrix[i][j];
}
[Link](colSum + " ");
}
[Link]();
}
}
S.R. Education Centre • Computer Science Project 59
Variable Description Table
Variable Data
Description
Name Type
matrix[][] int[][] Fixed size 4x3 grid mapping input elements.
Accumulator calculation variable summarizing horizontal row
rowSum int
paths.
Accumulator calculation variable summarizing vertical column
colSum int
paths.
Console Execution Output
Enter matrix elements for 4x3 grid:
1 2 3
4 5 6
7 8 9
10 11 12
MATRIX WITH ROW SUMS:
1 2 3 | Sum = 6
4 5 6 | Sum = 15
7 8 9 | Sum = 24
10 11 12 | Sum = 33
------------------------------------
Col Sum:22 26 30
S.R. Education Centre • Computer Science Project 60