0% found this document useful (0 votes)
2 views5 pages

Icse Class10 Java Programs Full

The document provides a comprehensive list of Java programs suitable for ICSE Class 10 students, covering various topics such as array manipulation, searching algorithms, sorting techniques, matrix operations, and number theory. Each program is accompanied by its code, demonstrating practical applications of Java programming concepts. The content serves as a valuable resource for students to learn and practice Java programming effectively.

Uploaded by

Safia Safia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Icse Class10 Java Programs Full

The document provides a comprehensive list of Java programs suitable for ICSE Class 10 students, covering various topics such as array manipulation, searching algorithms, sorting techniques, matrix operations, and number theory. Each program is accompanied by its code, demonstrating practical applications of Java programming concepts. The content serves as a valuable resource for students to learn and practice Java programming effectively.

Uploaded by

Safia Safia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ICSE Class 10 Java Programs (Complete List with

Code)

1. Input & Display Array


import [Link].*;
class ArrayInput {
public static void main() {
Scanner sc=new Scanner([Link]);
int a[]=new int[5];
for(int i=0;i<5;i++) a[i]=[Link]();
for(int i=0;i<5;i++) [Link](a[i]);
}
}

2. Linear Search
import [Link].*;
class LinearSearch {
public static void main() {
Scanner sc=new Scanner([Link]);
int a[]=new int[5];
for(int i=0;i<5;i++) a[i]=[Link]();
int key=[Link]();
boolean f=false;
for(int i=0;i<5;i++) if(a[i]==key) f=true;
[Link](f?"Found":"Not Found");
}
}

3. Binary Search
import [Link].*;
class BinarySearch {
public static void main() {
Scanner sc=new Scanner([Link]);
int a[]=new int[5];
for(int i=0;i<5;i++) a[i]=[Link]();
int key=[Link]();
int low=0,high=4;
while(low<=high){
int mid=(low+high)/2;
if(a[mid]==key){[Link]("Found");break;}
else if(a[mid]<key) low=mid+1;
else high=mid-1;
}
}
}

4. Bubble Sort
import [Link].*;
class BubbleSort{
public static void main(){
Scanner sc=new Scanner([Link]);
int a[]=new int[5];
for(int i=0;i<5;i++) a[i]=[Link]();
for(int i=0;i<4;i++)
for(int j=0;j<4-i;j++)
if(a[j]>a[j+1]){
int t=a[j]; a[j]=a[j+1]; a[j+1]=t;
}
for(int i=0;i<5;i++) [Link](a[i]+" ");
}
}
5. Selection Sort
import [Link].*;
class SelectionSort{
public static void main(){
Scanner sc=new Scanner([Link]);
int a[]=new int[5];
for(int i=0;i<5;i++) a[i]=[Link]();
for(int i=0;i<4;i++){
int min=i;
for(int j=i+1;j<5;j++)
if(a[j]<a[min]) min=j;
int t=a[i]; a[i]=a[min]; a[min]=t;
}
for(int i=0;i<5;i++) [Link](a[i]+" ");
}
}

6. Matrix Input & Display


import [Link].*;
class MatrixInput{
public static void main(){
Scanner sc=new Scanner([Link]);
int a[][]=new int[3][3];
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=[Link]();
for(int i=0;i<3;i++){
for(int j=0;j<3;j++)
[Link](a[i][j]+" ");
[Link]();
}
}
}

7. Main Diagonal
for(int i=0;i<3;i++)
[Link](a[i][i]+" ");

8. Secondary Diagonal
for(int i=0;i<3;i++)
[Link](a[i][2-i]+" ");

9. Sum Above Main Diagonal


int sum=0;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(j>i) sum+=a[i][j];

10. Sum Below Main Diagonal


int sum=0;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(i>j) sum+=a[i][j];

11. Transpose Matrix


for(int i=0;i<3;i++){
for(int j=0;j<3;j++)
[Link](a[j][i]+" ");
[Link]();
}

12. Identity Matrix Check


boolean flag=true;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++){
if(i==j && a[i][j]!=1) flag=false;
if(i!=j && a[i][j]!=0) flag=false;
}
[Link](flag?"Identity":"Not Identity");

13. Sparse Matrix


int zero=0;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(a[i][j]==0) zero++;
[Link](zero>4?"Sparse":"Not Sparse");

14. Mirror Matrix


for(int i=0;i<3;i++){
for(int j=2;j>=0;j--)
[Link](a[i][j]+" ");
[Link]();
}

15. Largest & Smallest in Matrix


int max=a[0][0],min=a[0][0];
for(int i=0;i<3;i++)
for(int j=0;j<3;j++){
if(a[i][j]>max) max=a[i][j];
if(a[i][j]<min) min=a[i][j];
}

16. Sum of Even & Odd in Matrix


int even=0,odd=0;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(a[i][j]%2==0) even+=a[i][j];
else odd+=a[i][j];

17. Prime Number


for(int i=2;i<n;i++)
if(n%i==0) { [Link]("Not Prime"); return; }
[Link]("Prime");

18. Palindrome Number


int rev=0,t=n;
while(n>0){ rev=rev*10+n%10; n/=10; }
[Link](t==rev?"Palindrome":"Not");
19. Automorphic Number
int sq=n*n;
[Link](sq%10==n%10?"Automorphic":"Not");

20. Niven Number


int s=0,t=n;
while(n>0){ s+=n%10; n/=10; }
[Link](t%s==0?"Niven":"Not");

21. Factorial
int f=1;
for(int i=1;i<=n;i++) f*=i;
[Link](f);

22. Fibonacci
int a=0,b=1;
for(int i=1;i<=n;i++){
[Link](a+" ");
int c=a+b; a=b; b=c;
}

23. Reverse String


String rev="";
for(int i=[Link]()-1;i>=0;i--)
rev+=[Link](i);

24. Count Vowels & Consonants


for(int i=0;i<[Link]();i++){
char ch=[Link](i);
if("aeiouAEIOU".indexOf(ch)>=0) v++;
else if([Link](ch)) c++;
}

25. Word Count


int count=1;
for(int i=0;i<[Link]();i++)
if([Link](i)==' ') count++;

26. Remove Spaces


String r="";
for(int i=0;i<[Link]();i++)
if([Link](i)!=' ') r+=[Link](i);

27. Change Case


char ch=[Link](i);
if([Link](ch))
r+=[Link](ch);
else r+=[Link](ch);

28. Frequency of Characters


for(char ch='a';ch<='z';ch++){
int c=0;
for(int i=0;i<[Link]();i++)
if([Link](i)==ch) c++;
if(c>0) [Link](ch+"="+c);
}

29. First Letter Capital


s=" "+s;
for(int i=0;i<[Link]()-1;i++)
if([Link](i)==' ')
[Link]([Link]([Link](i+1)));

30. Series 1+2+...+n


int sum=0;
for(int i=1;i<=n;i++) sum+=i;

31. Series 1²+2²+...+n²


int sum=0;
for(int i=1;i<=n;i++) sum+=i*i;

32. Method Overloading Area


void area(int s){[Link](s*s);}
void area(int l,int b){[Link](l*b);}
void area(double r){[Link](3.14*r*r);}

33. Method Overloading Volume


void volume(int s){[Link](s*s*s);}
void volume(int l,int b,int h){[Link](l*b*h);}

34. Method Overloading Sum


void add(int a,int b){[Link](a+b);}
void add(int a,int b,int c){[Link](a+b+c);}

35. Method Overloading Largest


void max(int a,int b){[Link](a>b?a:b);}
void max(int a,int b,int c){
int m=a; if(b>m)m=b; if(c>m)m=c;
[Link](m);
}

You might also like