Sure. Here are Programs 11–15 with proper ICSE comments.
Program 11: Perfect Number
import [Link].*;
class Perfect
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Variable Declaration
int n, sum = 0;
// Input
[Link]("Enter a number : ");
n = [Link]();
// Finding sum of factors excluding the number itself
for(int i = 1; i < n; i++)
{
if(n % i == 0)
sum = sum + i;
}
// Checking Perfect Number
if(sum == n)
[Link]("Perfect Number");
else
[Link]("Not a Perfect Number");
}
}
Program 12: Convert First Letter of Every
Word to Uppercase
import [Link].*;
class Capitalize
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Input string in lowercase
[Link]("Enter a sentence : ");
String s = [Link]();
// Adding space at beginning
s = " " + s;
String result = "";
// Converting first letter of each word to uppercase
for(int i = 1; i < [Link](); i++)
{
char ch = [Link](i);
if([Link](i - 1) == ' ')
result = result + [Link](ch);
else
result = result + ch;
}
// Display result
[Link]("New String : " + result);
}
}
Program 13: Count Vowels in a String
import [Link].*;
class VowelCount
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Input String
[Link]("Enter a string : ");
String s = [Link]();
int count = 0;
// Convert string to lowercase
s = [Link]();
// Counting vowels
for(int i = 0; i < [Link](); i++)
{
char ch = [Link](i);
if(ch=='a' || ch=='e' || ch=='i' ||
ch=='o' || ch=='u')
{
count++;
}
}
// Display Result
[Link]("Number of vowels = " + count);
}
}
Program 14: Display Character and Unicode
import [Link].*;
class UnicodeTable
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Input Sentence
[Link]("Enter a sentence : ");
String s = [Link]();
// Table Heading
[Link]("Character\tUnicode");
// Displaying each character with Unicode
for(int i = 0; i < [Link](); i++)
{
char ch = [Link](i);
[Link](ch + "\t\t" + (int)ch);
}
}
}
Program 15: Display Each Word with
Number of Characters
import [Link].*;
class WordLength
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Input Sentence
[Link]("Enter a sentence : ");
String s = [Link]();
// Splitting sentence into words
String words[] = [Link](" ");
// Table Heading
[Link]("Word\tCharacters");
// Displaying each word and its length
for(int i = 0; i < [Link]; i++)
{
[Link](words[i] +
"\t" +
words[i].length());
}
}
}
Comment Style Your Teacher Usually Expects
Use comments like:
// Variable Declaration
// Input Data
// Processing
// Checking Condition
// Display Result
These are short, neat, and preferred in most ICSE practical copies.
I can also give Programs 16–25 with comments, purpose, variable description, and sample
output in the same format.
give
Program 16: Frequency of Each Character in an Uppercase
String
import [Link].*;
class Frequency
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Input String in Uppercase
[Link]("Enter a string in uppercase : ");
String s = [Link]();
// Display frequency of each character
for(int i=0;i<[Link]();i++)
{
char ch = [Link](i);
int count = 0;
for(int j=0;j<[Link]();j++)
{
if(ch==[Link](j))
count++;
}
[Link](ch + " = " + count);
}
}
}
Program 17: Display Array Elements in Reverse Order
class ReverseArray
{
public static void main(String args[])
{
// Initializing Array
int a[]={10,20,30,40,50,60,70,80,90,100};
[Link]("Array in Reverse Order:");
// Display in reverse order
for(int i=9;i>=0;i--)
{
[Link](a[i]+" ");
}
}
}
Program 18: Sum, Average and Maximum of 10 Numbers
import [Link].*;
class ArrayOperation
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
int a[] = new int[10];
int sum=0,max=0;
// Input Array Elements
for(int i=0;i<10;i++)
{
[Link]("Enter Number : ");
a[i]=[Link]();
sum=sum+a[i];
if(i==0 || a[i]>max)
max=a[i];
}
double avg=(double)sum/10;
// Display Result
[Link]("Sum = "+sum);
[Link]("Average = "+avg);
[Link]("Maximum = "+max);
}
}
Program 19: Linear Search in Unsorted Array
import [Link].*;
class LinearSearch
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
int a[] = {25,18,45,67,12,89,34,56,90,10};
// Input Number to Search
[Link]("Enter Number to Search : ");
int num=[Link]();
boolean found=false;
// Linear Search
for(int i=0;i<10;i++)
{
if(a[i]==num)
{
found=true;
break;
}
}
if(found)
[Link]("Number Found");
else
[Link]("Number Not Found");
}
}
Program 20: Binary Search in Sorted Array
import [Link].*;
class BinarySearch
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Sorted Array
int a[]={10,20,30,40,50,60,70,80,90,100};
[Link]("Enter Number to Search : ");
int num=[Link]();
int low=0;
int high=9;
boolean found=false;
while(low<=high)
{
int mid=(low+high)/2;
if(a[mid]==num)
{
found=true;
break;
}
else if(num>a[mid])
low=mid+1;
else
high=mid-1;
}
if(found)
[Link]("Number Found");
else
[Link]("Number Not Found");
}
}
Program 21: Linear Search for a Name in String Array
import [Link].*;
class NameSearch
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
String name[]={
"AMAN","RAHUL","KARTIK","ROHAN","AMIT",
"RAVI","PRIYA","NEHA","SONU","ARYAN"};
// Input Name
[Link]("Enter Name to Search : ");
String n=[Link]();
boolean found=false;
for(int i=0;i<10;i++)
{
if(name[i].equalsIgnoreCase(n))
{
found=true;
break;
}
}
if(found)
[Link]("Name Found");
else
[Link]("Name Not Found");
}
}
Reply "next" and I'll give Programs 22–25 (Bubble Sort, Selection Sort, Matrix Transpose,
Diagonal Sum) with comments.
YES
Program 22: Bubble Sort (Alphabetical
Order)
import [Link].*;
class BubbleSortNames
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Array Declaration
String name[] = new String[10];
// Input Names
[Link]("Enter 10 Names : ");
for(int i=0;i<10;i++)
{
name[i] = [Link]();
}
// Bubble Sort
for(int i=0;i<9;i++)
{
for(int j=0;j<9-i;j++)
{
if(name[j].compareTo(name[j+1]) > 0)
{
String temp = name[j];
name[j] = name[j+1];
name[j+1] = temp;
}
}
}
// Display Sorted Names
[Link]("Names in Alphabetical Order :");
for(int i=0;i<10;i++)
{
[Link](name[i]);
}
}
}
Program 23: Selection Sort (Descending
Order)
import [Link].*;
class SelectionSort
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Array Declaration
int a[] = new int[10];
// Input Numbers
[Link]("Enter 10 Numbers : ");
for(int i=0;i<10;i++)
{
a[i] = [Link]();
}
// Selection Sort in Descending Order
for(int i=0;i<9;i++)
{
int pos = i;
for(int j=i+1;j<10;j++)
{
if(a[j] > a[pos])
pos = j;
}
int temp = a[i];
a[i] = a[pos];
a[pos] = temp;
}
// Display Sorted Array
[Link]("Numbers in Descending Order :");
for(int i=0;i<10;i++)
{
[Link](a[i] + " ");
}
}
}
Program 24: Matrix and Transpose
import [Link].*;
class MatrixTranspose
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Array Declaration
int a[][] = new int[3][3];
// Input Matrix
[Link]("Enter Matrix Elements : ");
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
a[i][j] = [Link]();
}
}
// Display Original Matrix
[Link]("Original Matrix :");
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
[Link](a[i][j] + "\t");
}
[Link]();
}
// Display Transpose
[Link]("Transpose Matrix :");
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
[Link](a[j][i] + "\t");
}
[Link]();
}
}
}
Program 25: Sum of Left and Right Diagonal
import [Link].*;
class DiagonalSum
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
// Array Declaration
int a[][] = new int[5][5];
int leftSum = 0;
int rightSum = 0;
// Input Matrix
[Link]("Enter Matrix Elements : ");
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
a[i][j] = [Link]();
}
}
// Calculate Left Diagonal Sum
for(int i=0;i<5;i++)
{
leftSum = leftSum + a[i][i];
}
// Calculate Right Diagonal Sum
for(int i=0;i<5;i++)
{
rightSum = rightSum + a[i][4-i];
}
// Display Result
[Link]("Left Diagonal Sum = " + leftSum);
[Link]("Right Diagonal Sum = " + rightSum);
}
}
Practical Copy Tip (ICSE)
Before every program, write:
Purpose:
To (state what the program does).
Variable Description:
Variable Data Type Purpose
i int Loop counter
sum int Stores sum
a[] int array Stores numbers
Output:
(Write one sample run)
This format usually earns better practical-file marks because it looks complete and organized.
1. Area of Triangle using Static Method
class Triangle
{
static double area(double b, double h)
{
return 0.5 * b * h;
}
public static void main(String args[])
{
double a = area(10, 5);
[Link]("Area = " + a);
}
}
2. Examples of Pure and Impure Methods
class MethodDemo
{
// Pure Method
int square(int n)
{
return n * n;
}
// Impure Method
void display()
{
[Link]("Hello");
}
public static void main(String args[])
{
MethodDemo obj = new MethodDemo();
[Link]("Square = " + [Link](5));
[Link]();
}
}
Pure Method: Returns a value and does not print/input anything.
Impure Method: Performs input/output operations.
3. ShowRoom Class
import [Link].*;
class ShowRoom
{
String name;
long mobno;
double cost, dis, amount;
void input()
{
Scanner sc = new Scanner([Link]);
[Link]("Enter Name : ");
name = [Link]();
[Link]("Enter Mobile No : ");
mobno = [Link]();
[Link]("Enter Cost : ");
cost = [Link]();
}
void calculate()
{
if(cost <= 10000)
dis = cost * 0.05;
else if(cost <= 20000)
dis = cost * 0.10;
else if(cost <= 35000)
dis = cost * 0.15;
else
dis = cost * 0.20;
amount = cost - dis;
}
void display()
{
[Link]("Name : " + name);
[Link]("Mobile : " + mobno);
[Link]("Amount Payable : " + amount);
}
public static void main(String args[])
{
ShowRoom obj = new ShowRoom();
[Link]();
[Link]();
[Link]();
}
}
4. Function Overloading for Volume
class FOverload
{
void volume(int s)
{
[Link]("Volume of Cube = " + (s*s*s));
}
void volume(double r, double h)
{
[Link]("Volume of Cylinder = "
+ (3.14*r*r*h));
}
void volume(int l, int b, int h)
{
[Link]("Volume of Cuboid = "
+ (l*b*h));
}
public static void main(String args[])
{
FOverload obj = new FOverload();
[Link](4);
[Link](3.5, 5.0);
[Link](4, 5, 6);
}
}
5. MyDate Constructor Program
class MyDate
{
int day, month, year;
MyDate()
{
day = 1;
month = 1;
year = 1900;
}
MyDate(int d, int m, int y)
{
day = d;
month = m;
year = y;
}
void display()
{
[Link](day + "/" + month + "/" + year);
}
public static void main(String args[])
{
MyDate d1 = new MyDate();
MyDate d2 = new MyDate(30, 5, 2026);
[Link]();
[Link]();
}
}
6. Wrapper Class Variables using new
Operator
class WrapperDemo
{
public static void main(String args[])
{
Integer a = new Integer(100);
Double b = new Double(25.5);
Character c = new Character('A');
[Link](a);
[Link](b);
[Link](c);
}
}
7. Capital, Small, Digit or Special Character
import [Link].*;
class CheckChar
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
[Link]("Enter a character : ");
char ch = [Link]().charAt(0);
Character obj = new Character(ch);
if([Link](obj))
[Link]("Capital Letter");
else if([Link](obj))
[Link]("Small Letter");
else if([Link](obj))
[Link]("Digit");
else
[Link]("Special Symbol");
}
}
8. Biggest and Smallest Number from n
Numbers
import [Link].*;
class BigSmall
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
[Link]("How many numbers? ");
int n = [Link]();
int num, big = Integer.MIN_VALUE,
small = Integer.MAX_VALUE;
for(int i=1;i<=n;i++)
{
[Link]("Enter Number : ");
num = [Link]();
if(num > big)
big = num;
if(num < small)
small = num;
}
[Link]("Biggest = " + big);
[Link]("Smallest = " + small);
}
}
9. Menu Driven Program using Switch
import [Link].*;
class MenuProgram
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
[Link]("1. Sum of Series");
[Link]("2. Display Series");
[Link]("Enter Choice : ");
int ch = [Link]();
switch(ch)
{
case 1:
int x = [Link]();
long s = 0;
for(int i=1;i<=20;i++)
{
if(i%2==0)
s -= [Link](x,i);
else
s += [Link](x,i);
}
[Link]("Sum = " + s);
break;
case 2:
int n = 0;
for(int i=1;i<=5;i++)
{
n = n*10 + 1;
[Link](n + " ");
}
break;
default:
[Link]("Invalid Choice");
}
}
}
10. Parameterized Method to Check
Palindrome Number
import [Link].*;
class Palindrome
{
void check(int n)
{
int temp = n;
int rev = 0;
while(n > 0)
{
int d = n % 10;
rev = rev * 10 + d;
n = n / 10;
}
if(temp == rev)
[Link]("Palindrome Number");
else
[Link]("Not Palindrome Number");
}
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
[Link]("Enter Number : ");
int n = [Link]();
Palindrome obj = new Palindrome();
[Link](n);
}
}