Afrin Project ?
Afrin Project ?
Name:- SK AFRIN
Class:- X
Roll no:- 50
Section:- F
Subject:- COMPUTER
Session:- 2024-2025
1 | Page
PREFACE
In today’s world of a vast competition in the academic field only
studying text book prescribed in the curriculum is not enough. In order
to stay ahead in the race one needs to gain additional information from
the books, from the library, websites, archives, etc. Another necessary
part of our learning process is project work. Project involves a process
of learning and understanding a project work increases out practical
knowledge and interest in the subject. The extensive research work
associated with it familiarizes with a lot of facts that were hither to
unknown to us. In the following assignment I have tried to shed light on
the topic “Programming in Java”. I hope my endeavour will be
appreciated by the examiner.
2 | Page
ACKNOWLEDGEMENT
I would like to convey my heart felt gratitude to CISCE for giving me the
opportunity of doing this project. I would also thank my parents for
providing me with all the needed materials and for helping me finish
the assignment within the proper time. I would also thank our Principal
Sir and teacher for the same. Last but certainly not the least; I would
like to thank GOD for guiding me and watching over every step that I
take.
3 | Page
CONTENTS:-
SL.NO. TOPICS PAGE NO:-
(i) PREFACE 1
(ii) ACKNOWLEDGEMENT 2
(iii) CONTENTS 3
(iv) INTRODUCTION 4
1 PARKING LOT 6-9
2 BOOKFAIR 10-13
3 SHOW ROOM 14-18
4 BUBBLE SORT 19-21
5 TECH NUMBER 22-24
6 NIVEN NUMBER 25-27
7 SELECTION SORT 28-32
8 SWITCH CASE 33-35
9 STRING PATTERN 36-38
10 PALINDROME WORD 39-41
11 TWIN PRIME 42-44
12 PRIME PALINDROME 45-48
4 | Page
13 SPY NUMBER 49-51
14 TRANSPOSE MATRIX 52-55
15 ASTERISK TRIANGLE 56-58
16 VOWEL FREQUENCY 59-61
17 MATRIX 62-66
MULTIPLICATION
18 PALINDROME ARRAY 67-69
19 CHARACTER 70-72
FREQUENCY
20 LINEAR SEARCH 73-75
21 BINARY SEARCH 76-79
22 UNIQUE NUMBER 80-82
23 NUMBER REVERSE 83-85
24 SUM MATRIX 86-88
25 PIGLATIN 89-91
(v) CONCLUSION 92
5 | Page
Program 1:-
import java.util.Scanner;
class ParkingLot
int vno;
int hours;
double bill;
6 | Page
void input()
vno = in.nextInt();
System.out.print("Enter hours:-");
hours = in.nextInt();
void calculate(){
bill = 3;
} else {
if(bill>1);
bill=bill+3;
for(int i=1;i<hours;i++)
bill=bill+1.50;
7 | Page
}
void display()
void display()
ob.input();
ob.calculate();
ob.display();
8 | Page
Input and Output
9 | Page
Variable Description
10 | Page
VARIABLE NAME VARIABLE TYPE VARIABLE
DESCRIPTION
bill double To calculate the bill
amount
vno int To store the vehicle
numbers
hours int To store the number
of hours
i int To execute the loop
11 | Page
Program 2:-
import java.util.Scanner;
class BookFair
String bname;
double price;
BookFair()
bname = "";
price = 0.0;
void input()
bname = in.nextLine();
12 | Page
System.out.print("Enter price of the book: ");
price = in.nextDouble();
void calculate()
double disc;
else
price -= disc;
void display()
13 | Page
System.out.println("Price after discount: " + price);
void display()
ob.input();
ob.calculate();
ob.display();
14 | Page
Input and Output
15 | Page
Variable Description
16 | Page
Program 3:-
import java.util.Scanner;
class ShowRoom
String name;
long mobno;
double cost,dis,amount;
ShowRoom()
name ="";
mobno = 0L;
cost = 0.0;
dis = 0.0;
amount = 0.0;
void input()
17 | Page
{
name = sc.nextLine();
mobno = sc.nextLong();
cost = sc.nextDouble();
void calculate()
if(cost<=10000)
18 | Page
{
else
void display()
void display()
ob.input();
ob.calculate();
19 | Page
ob.display();
20 | Page
Variable Description:-
21 | Page
Program 4:-
import java.util.Scanner;
class BubbleSort
for(int i=0;i<15;i++)
a[i]=sc.nextInt();
for(int i=0;i<15;i++)
22 | Page
{
for(int j=0;j<15-1-i;j++)
if(a[j]>a[j+1])
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
for(int i=0;i<15;i++)
System.out.print(a[i]+"\t");
23 | Page
Input and Output:-
24 | Page
Variable Description:-
25 | Page
Program 5:-
import java.util.*;
int j = i % 100;
int k= i / 100;
int sum = j+ k;
26 | Page
if (i == sum * sum)
System.out.println(i);
27 | Page
Variable Description:-
28 | Page
half of the number
Program 6:-
import java.util.Scanner;
class NivenNumber
int n, num, r,
29 | Page
sum = 0;
n = sc.nextInt();
num = n;
r = num % 10;
sum = sum + r;
if (n % sum == 0)
System.out.println("Niven Number");
else
30 | Page
}
31 | Page
Variable Description:-
32 | Page
sum int To store the sum of
the numbers.
Program 7:-
import java.util.*;
class SelectionSort
33 | Page
public void display()
String min;
int pos;
for(int i=0;i<40;i++)
a[i]=sc.nextLine();
for(int i=0;i<40;i++)
min=a[i];
pos=i;
for(int j=i+1;j<40;j++)
if(min.compareTo(a[j])<0)
min=a[j];
34 | Page
pos=j;
String temp=a[i];
a[i]=a[pos];
a[pos]=temp;
for(int i=0;i<40;i++)
System.out.println(a[i]);
35 | Page
36 | Page
37 | Page
Variable Description:-
38 | Page
Program 8:-
/*Floyd's Triangle*/
import java.util.*;
class floydstriangle
void display()
int a = 1;
System.out.print(a++ + "\t");
System.out.println();
39 | Page
Input and output:-
40 | Page
Variable description:-
41 | Page
Program 9:-
import java.util.*;
class icse
String s = "ICSE";
42 | Page
}
System.out.println();
43 | Page
Variable Description:-
44 | Page
Program 10:-
word.*/
import java.util.*;
class PalindromeWord
a=a.trim();
int l=a.length();
a=a.toLowerCase();
String w="";
45 | Page
for(int i=l-1;i>=0;i--)
char ch=a.charAt(i);
w=w+ch;
char fl=a.charAt(0);
char ll=a.charAt(l-1);
if(fl==ll)
if(a.equalsIgnoreCase(w))
System.out.println("Palindromic Word!");
else
System.out.println("Special Word!");
else
46 | Page
Input and Output:-
47 | Page
Variable Description:-
48 | Page
letter of the string.
ll char To determine the last
letter of the string.
Program 11:-
import java.util.*;
class TwinPrime
for(int i=2;i<=100;i++)
49 | Page
if(isPrime(i)==true && isPrime(i+2)==true)
System.out.print(i+","+(i+2));
System.out.println();
boolean isPrime(int n)
int c=0;
for(int i=1;i<=n;i++)
if(n%i==0)
c++;
if(c==2)
return true;
else
return false;
50 | Page
}
51 | Page
Variable Description:-
52 | Page
Program 12:-
import java.util.*;
class PrimePalindrome
53 | Page
if(isPrime(n)==true && isPrime(x)==true)
boolean isPrime(int i)
int c=0;
boolean f=false;
for(int j=1;j<=i;j++)
if(i%j==0)
c++;
if(c==2)
f=true;
return f;
boolean isPalin(int i)
54 | Page
int q=i;
int s=0;
while(i!=0)
int t=i%10;
s=(s+t)*10;
i=i/10;
s=s/10;
if(q==s)
return true;
else
return false;
55 | Page
Variable Description:-
57 | Page
Program 13:-
import java.util.*;
class SpyNumber
int p=1;
int s=0;
while(n!=0)
int t=n%10;
p=p*t;
s=s+t;
n=n/10;
if(p==s)
58 | Page
System.out.println("Spy Number!");
else
59 | Page
Input and Output:-
60 | Page
Variable description:-
61 | Page
Program 14:-
in 2D array*/
import java.util.*;
class TransposeMatrix
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=sc.nextInt();
62 | Page
System.out.println("Original Matrix:");
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
System.out.print(a[i][j]+"\t");
System.out.println();
System.out.println();
System.out.println("Transposed Matrix:");
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
System.out.print(a[j][i]+"\t");
System.out.println();
63 | Page
}
64 | Page
Variable Description:-
65 | Page
Program 15:-
import java.util.*;
class starpattern
for(int i=1;i<=3;i++)
for(int j=1;j<=3-i;j++)
System.out.print(" ");
for(int k=1;k<=(i*2)-1;k++)
System.out.print("* ");
66 | Page
}
System.out.println();
67 | Page
Variable Description:-
68 | Page
Program 16:-
it.*/
import java.util.Scanner;
class VowelFrequency
while (sc.hasNext())
69 | Page
String Word = sc.next();
if (word.equals("."))
break;
int freq = 0;
freq++;
70 | Page
Input and output:-
71 | Page
Variable Description:-
72 | Page
Program 17:-
message.*/
import java.util.*;
class MatrixMultiplication
73 | Page
int m=sc.nextInt();
int n=sc.nextInt();
int p=sc.nextInt();
int q=sc.nextInt();
if(n==p)
int c=1;
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
MatrixA[i][j]=sc.nextInt();
74 | Page
}
int c1=1;
for(int i=0;i<p;i++)
for(int j=0;j<q;j++)
MatrixB[i][j]=sc.nextInt();
for(int i=0;i<m;i++)
for(int j=0;j<q;j++)
int s=0;
for(int x=0;x<n;x++)
s+=MatrixA[i][x]*MatrixB[x][j];
MatrixC[i][j]=s;
75 | Page
}
for(int i=0;i<m;i++)
for(int j=0;j<q;j++)
System.out.print(MatrixC[i][j]+"\t");
System.out.println();
else
76 | Page
Input and Output:-
77 | Page
Variable Description:-
78 | Page
array.
MatrixB int To declare another
double dimension
integer array.
MatrixC int To declare another
double dimension
integer array.
(product)
Program 18:-
import java.util.Scanner;
class PalindromeArray
79 | Page
{
int n=sc.nextInt();
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
for(int i=0;i<n;i++)
if(isPalindrome(a[i])==true)
System.out.print(a[i]+"\t");
boolean isPalindrome(int n)
int m=n;
int sum=0;
80 | Page
boolean f=false;
while(n!=0)
int t=n%10;
sum=(sum+t)*10;
n=n/10;
sum=sum/10;
if(sum==m)
f=true;
return f;
81 | Page
Variable Description:-
82 | Page
VARIABLE NAME VARIABLE TYPE VARIABLE
DESCRIPTION
n int To store the size of
the array .
a int To declare the integer
array.
i int To execute the loop.
x int To accept the value in
order to check it
further.
m int To copy the original
value of x.
sum int To calculate the sum.
f boolean To finalise the return
value.
t int To temporarily store
the digit of a number.
83 | Page
Program 19:-
each character.*/
import java.util.*;
class frequency
frequency[(int) str.charAt(i)]++;
84 | Page
}
if (frequency[i] != 0)
85 | Page
Input and Output:-
86 | Page
Variable Description:-
87 | Page
Program 20:-
*/
import java.util.Scanner;
class LinearSearch
int s=sc.nextInt();
boolean f=false;
for(int i=0;i<10;i++)
a[i]=sc.nextInt();
88 | Page
for(int i=0;i<10;i++)
if(s==a[i])
f=true;
break;
if(f==false)
System.out.println("Not Found!");
89 | Page
Input and Output:-
90 | Page
Variable Description:-
91 | Page
Program:-21
import java.util.*;
class BinarySearch
void main()
boolean f=false;
for(int i=0;i<10;i++)
a[i]=sc.nextLine();
String s=sc.nextLine();
92 | Page
int ub=9,lb=0,mid;
while(ub>=lb)
mid=(ub+lb)/2;
if(a[mid].compareTo(s)>0)
ub=mid-1;
else if(a[mid].compareTo(s)<0)
lb=mid+1;
else
f=true;
break;
if(f==false)
System.out.println("Not Found");
93 | Page
Input and Output:-
94 | Page
Variable Description:-
95 | Page
mid int To determine the
middle of the array.
Program 22:-
no. or not.*/
import java.util.*;
class UniqueNumber
String a=Integer.toString(n);
int l=a.length();
boolean f=true;
96 | Page
for(int i=0;i<l;i++)
char ch=a.charAt(i);
x[i]=ch;
for(int i=0;i<l-1;i++)
for(int j=i+1;j<l;j++)
if(x[i]==x[j])
f=false;
break;
if(f==true)
else
97 | Page
}
98 | Page
Variable Description:-
99 | Page
array.
f boolean To finalise the return
value.
i int To execute the outer
loop.
ch char To extract characters
from the string.
j int To execute the inner
loop.
Program 23:-
import java.util.Scanner;
class ReverseNumber
100 | Page
public void display()
int num=0;
num = in.nextInt();
while( num != 0 )
num = num/10;
101 | Page
Input and Output:-
102 | Page
Variable Desciption:-
103 | Page
VARIABLE NAME VARIABLE TYPE VARIABLE
DESCRIPTION
num int To store the original
number.
reversenumber int To store the reverse
number.
104 | Page
Program 24:-
import java.util.*;
int l = 0;
int r= 0;
l += matrix[i][i];
r += matrix[i][matrix.length - 1 - i];
105 | Page
Input and output:-
106 | Page
Variable Description:-
107 | Page
Program 25:-
import java.util.*;
class Piglatin
int l=a.length();
a=a.toUpperCase();
int i;
for(i=0;i<l;i++)
char ch=a.charAt(i);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
break;
System.out.println(a+"\n"+a.substring(i,l)+a.substring(0,i)+"AY");
108 | Page
}
109 | Page
Variable Description:-
110 | Page
Conclusion
Java is an object-oriented programming language. It is a general-
purpose programming language, mainly designed to run developed java
code on all platforms that support Java without recompilation. As we all
know, Java is one of the most popular and in-demand programming
languages to learn and it was one of the first languages to standardise
high-level threading utilities. Java project is a must for aspiring
developers. This project helps developers develop real-world projects
to hone their skills and materialise their theoretical knowledge into
practical experience. Java has significant advantages both as a
commercial language and also as a teaching language. Java project
provides rigorous compiletime error checking typically associated with
Pascal, allowing instructors to introduce students to GUI programming,
networking, threads, and other important concepts used in modern-day
software. Overall, the java project gives a complete design for the
extended language.
111 | Page