0% found this document useful (0 votes)
4 views111 pages

Afrin Project ?

Uploaded by

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

Afrin Project ?

Uploaded by

arijitlaha2021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 111

St Paul’s Academy

Name:- SK AFRIN

Class:- X

Roll no:- 50

Section:- F

Subject:- COMPUTER

Topic:- JAVA PROGRAMMING

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()

Scanner in = new Scanner(System.in);

System.out.print("Enter vehicle number:-");

vno = in.nextInt();

System.out.print("Enter hours:-");

hours = in.nextInt();

void calculate(){

if (hours <= 1){

bill = 3;

} else {

if(bill>1);

bill=bill+3;

for(int i=1;i<hours;i++)

bill=bill+1.50;

7 | Page
}

void display()

System.out.println("Hours: " + hours);

System.out.println("Bill: " + bill);

void display()

ParkingLot ob = new ParkingLot();

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()

Scanner in = new Scanner(System.in);

System.out.print("Enter name of the book: ");

bname = in.nextLine();

12 | Page
System.out.print("Enter price of the book: ");

price = in.nextDouble();

void calculate()

double disc;

if (price <= 1000)

disc = price * 0.02;

else if (price <= 3000)

disc = price * 0.1;

else

disc = price * 0.15;

price -= disc;

void display()

System.out.println("Book Name: " + bname);

13 | Page
System.out.println("Price after discount: " + price);

void display()

BookFair ob = new BookFair();

ob.input();

ob.calculate();

ob.display();

14 | Page
Input and Output

15 | Page
Variable Description

VARIABLE NAME VARIABLE TYPE VARIABLE DECRIPTION


bname String To store the name of
the book
price double To store and calculate
the book of the price.

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
{

Scanner sc = new Scanner(System.in);

System.out.println("Enter the name of the customer");

name = sc.nextLine();

System.out.println("Enter the Mobile Number");

mobno = sc.nextLong();

System.out.println("Enter the cost of the item purchased");

cost = sc.nextDouble();

void calculate()

if(cost<=10000)

dis = 0.5 * cost;

else if(cost>10000 && cost<=20000)

dis = 0.10 * cost;

else if(cost>20000 && cost<=35000)

18 | Page
{

dis = 0.15 * cost;

else

dis = 0.20 * cost;

amount = cost - dis;

void display()

System.out.println("Customer Name : "+ name);

System.out.println("Customer Mobile:" + mobno);

System.out.println("Amount to be Paid : "+ amount);

void display()

ShowRoom ob = new ShowRoom();

ob.input();

ob.calculate();

19 | Page
ob.display();

Input and Output:-

20 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
name String To store the name of
the customer
mobno long To store the mobile
number of the
customer.
cost double To store the total cost
of the item purchased
dis double To calculate the
discount
amount double To calculate and
display the final
amount.

21 | Page
Program 4:-

/*Write a program to input 15 integer elements in an array and sort


them in ascending order using the bubble sort technique.*/

import java.util.Scanner;

class BubbleSort

public void disp()

Scanner sc=new Scanner(System.in);

int a[]=new int[15];

System.out.println("Enter the array to be sorted:");

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;

System.out.println("The sorted array is:");

for(int i=0;i<15;i++)

System.out.print(a[i]+"\t");

23 | Page
Input and Output:-

24 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
a int To declare an integer
array
i int To take input & give
output of the
unsorted & sorted
array respectively, and
also to execute the
outer loop while
sorting
j int To execute the inner
loop while sorting.

25 | Page
Program 5:-

/* WAP to generate all 4-digit tech numbers.*/

import java.util.*;

public class TechNumbers

public void display()

for (int i = 1000; i <= 9999; i++)

int j = i % 100;

int k= i / 100;

int sum = j+ k;

26 | Page
if (i == sum * sum)

System.out.println(i);

Input and Output:-

27 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
i int To execute the loop
j int To dissect the first half
of the number
k int To dissect the second

28 | Page
half of the number

Program 6:-

/*WAP to accept a no. and check and display whether it is

a Niven no. or not.*/

import java.util.Scanner;

class NivenNumber

public void display ()

int n, num, r,

29 | Page
sum = 0;

Scanner sc = new Scanner(System.in);

System.out.print("Enter the number");

n = sc.nextInt();

num = n;

while (num > 0)

r = num % 10;

sum = sum + r;

num = num / 10;

if (n % sum == 0)

System.out.println("Niven Number");

else

System.out.println("Not Niven Number");

30 | Page
}

Input and Output:-

31 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
n int To the store a copy of
the original number.
num int To store the original
number.
r int To store the value
after remainder
division.

32 | Page
sum int To store the sum of
the numbers.

Program 7:-

/*WAP to input 40 words in an array. Arrange these

names in descending number of letters using the

selection sort technique.*/

import java.util.*;

class SelectionSort

33 | Page
public void display()

Scanner sc=new Scanner(System.in);

String min;

int pos;

String a[]=new String[40];

System.out.println("Enter the array of strings to be sorted:");

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;

System.out.println("The sorted array of string is:");

for(int i=0;i<40;i++)

System.out.println(a[i]);

Input and output:-

35 | Page
36 | Page
37 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
min String To determine the
content of the
particular position
while sorting.
pos int To determine the
position while sorting.
a String To declare the array.
i int To execute the outer
loop.
j int To execute the inner
loop.
temp String To update the
contents.

38 | Page
Program 8:-

/*Floyd's Triangle*/

import java.util.*;

class floydstriangle

void display()

int a = 1;

for (int i = 1; i <= 5; i++) {

for (int j = 1; j <= i; j++) {

System.out.print(a++ + "\t");

System.out.println();

39 | Page
Input and output:-

40 | Page
Variable description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
a int To print the pattern in
the increasing number
of order.
i int To execute the outer
loop.
j int To execute the inner
loop.

41 | Page
Program 9:-

import java.util.*;

class icse

public void display()

String s = "ICSE";

for(int i = 0; i< s.length(); i++)

for(int j = 0; j <= i; j++)

System.out.print(s.charAt(j) + " ");

42 | Page
}

System.out.println();

Input and Output:-

43 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
s String To store the string.
i int To execute the outer
loop.
j int To execute the inner
loop.

44 | Page
Program 10:-

/*WAP to accept a word, and check and print

whether the word is a palindrome or only a special

word.*/

import java.util.*;

class PalindromeWord

public void disp(String a)

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

System.out.println("Neither Palindromic nor Special!");

46 | Page
Input and Output:-

47 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
a String To take the input of
the string.
l int To count the length of
the string.
w String To store the modified
string.
i int To execute the loop.
ch Char To determine the
character at the very
position.
fl char To determine the first

48 | Page
letter of the string.
ll char To determine the last
letter of the string.

Program 11:-

/*WAP to print all twin-primes ranging from 1 to 100.*/

import java.util.*;

class TwinPrime

public void disp()

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
}

Input and Output:-

51 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
i int To execute the loops.
n int To accept the values in
order to check it
further.
c int To act as a counter.

52 | Page
Program 12:-

/*WAP to input a pair of numbers and whether it is

prime or a palindrome or not.*/

import java.util.*;

class PrimePalindrome

public void disp(int n,int x)

53 | Page
if(isPrime(n)==true && isPrime(x)==true)

System.out.println("Both the numbers are Prime!");

if(isPalin(n)==true && isPalin(x)==true)

System.out.println("Both the numbers are Palindromic!");

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;

Input and Output:-

55 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
n int To store one number.
56 | Page
x int To store another
number.
I int To accept the value in
order to check it
further.
c int To act as a counter in
order to check it a
prime number.
f boolean To finalise the return
value.
j int To execute the loop.
q int To copy the original
value of I.
s int To calculate the sum.
t int To temporarily store
the digit of the sum.

57 | Page
Program 13:-

/*WAP to accept a number and check and display

whether it is a spy number or not.*/

import java.util.*;

class SpyNumber

public void disp(int n)

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

System.out.println("Not a Spy Number!");

59 | Page
Input and Output:-

60 | Page
Variable description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
n int To take input from the
user.
p int To calculate the
product.
S int To calculate the sum.
t int To temporarily store
the digit of the
number.

61 | Page
Program 14:-

/*WAP to print the transpose form of a (3x3) matrix

in 2D array*/

import java.util.*;

class TransposeMatrix

public void disp()

Scanner sc=new Scanner(System.in);

int a[][]=new int [3][3];

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
}

Input and Output:-

64 | Page
Variable Description:-

VARIABLE NAME VARIBL TYPE VARIABLE


DESCRIPTION
a int To declare the double
dimension integer
array.
i int To execute the outer
loop.
j int To execute the inner
loop.

65 | Page
Program 15:-

import java.util.*;

class starpattern

public void disp()

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();

Input and Output:-

67 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
i int To execute the outer
main loop.
j int To execute sub loop.
k int To execute another
sub loop.

68 | Page
Program 16:-

/*WAP to input a sentence from the user and display

each word with the frequency of vowel characters present in

it.*/

import java.util.Scanner;

class VowelFrequency

public void display()

Scanner sc = new Scanner(System.in);

System.out.println("Enter a sentence :");

while (sc.hasNext())

69 | Page
String Word = sc.next();

String word = Word.toUpperCase();

if (word.equals("."))

break;

int freq = 0;

for (int i = 0; i < word.length(); i++)

if (word.charAt(i) == 'A' ||word.charAt(i) == 'E' ||


word.charAt(i) == 'I' ||word.charAt(i) == 'O' ||word.charAt(i) == 'U')

freq++;

System.out.println(Word + "\t\t" + freq);

70 | Page
Input and output:-

71 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
freq int To store the frequency
of each vowel in a
word.
i int To execute the loop .
word String To take input of the
word from the user.

72 | Page
Program 17:-

/*WAP to enter matrix A of (mxn) order and matrix B of

(pxq) order and display the product in matrix C if

multiplication is possible, otherwise display the relevant

message.*/

import java.util.*;

class MatrixMultiplication

public void disp()

Scanner sc=new Scanner(System.in);

System.out.println("Enter the number of rows for Matrix A:");

73 | Page
int m=sc.nextInt();

System.out.println("Enter the number of columns for Matrix A:");

int n=sc.nextInt();

System.out.println("Enter the number of rows for Matrix B:");

int p=sc.nextInt();

System.out.println("Enter the number of columns for Matrix B:");

int q=sc.nextInt();

int MatrixA [][]=new int[m][n];

int MatrixB [][]=new int[p][q];

int MatrixC [][]=new int [m][q];

if(n==p)

System.out.println("Enter the elements for Matrix A:");

int c=1;

for(int i=0;i<m;i++)

System.out.println("Enter the elements for Row "+c++);

for(int j=0;j<n;j++)

MatrixA[i][j]=sc.nextInt();

74 | Page
}

System.out.println("Enter the elements for Matrix B:");

int c1=1;

for(int i=0;i<p;i++)

System.out.println("Enter the elements for Row "+c1++);

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
}

System.out.println("The Product of the two Matrices is:"+"\n");

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

System.out.println("Matrix Multiplication not possible for the given


order!");

76 | Page
Input and Output:-

77 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
m int To store the number
of rows of MatrixA.
n int To store the number
of coloums of MatrixA.
P int To store the number
of rows of MatrixB.
q int To store the number
of coloums of MatrixB
MatrixA int To declare one double
dimension integer

78 | Page
array.
MatrixB int To declare another
double dimension
integer array.
MatrixC int To declare another
double dimension
integer array.
(product)

Program 18:-

/*WAP to enter n integers in an array and display all

palindromic integers present in the array.*/

import java.util.Scanner;

class PalindromeArray

public void display()

79 | Page
{

Scanner sc=new Scanner(System.in);

System.out.println("Enter the size of the array:");

int n=sc.nextInt();

int a[]=new int[n];

System.out.println("Enter the number for the array:");

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

a[i]=sc.nextInt();

System.out.println("The palindromic number(s) present in the entered


array are:");

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;

Input and Output:-

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:-

/* WAP to enter any sentence and display the frequency of

each character.*/

import java.util.*;

class frequency

public void display()

String str = "I love Computer";

int frequency[] = new int [256];

for (int i = 0; i < str.length(); i++)

frequency[(int) str.charAt(i)]++;

84 | Page
}

for (int i = 0; i < frequency.length; i++)

if (frequency[i] != 0)

System.out.println((char) i + " - " + frequency[i]);

85 | Page
Input and Output:-

86 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARAIBALE


DESCRIPTION
str String To take the input of
the sentence.
i int To excute the loop.
frequency int To store the number
of vowels in a word.

87 | Page
Program 20:-

/*WAP to input 10 numbers and search for a particular

number using linear search.

*/

import java.util.Scanner;

class LinearSearch

public void disp()

Scanner sc=new Scanner(System.in);

int a[]=new int[10];

System.out.println("Enter the Search Element:");

int s=sc.nextInt();

System.out.println("Enter the array:");

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;

System.out.println("Found at position "+i+'!');

break;

if(f==false)

System.out.println("Not Found!");

89 | Page
Input and Output:-

90 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
a int To declare integer
array.
s int To store the search
element.
f boolean To finalise the output
value.
i int To execute the loop.

91 | Page
Program:-21

/*WAP to input 10 words and search for a particular word

using binary search.*/

import java.util.*;

class BinarySearch

void main()

Scanner sc=new Scanner(System.in);

boolean f=false;

String a[]=new String[10];

System.out.println("Enter a sorted array:");

for(int i=0;i<10;i++)

a[i]=sc.nextLine();

System.out.println("Enter the search element:");

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

System.out.println("Found at position "+mid+'!');

f=true;

break;

if(f==false)

System.out.println("Not Found");

93 | Page
Input and Output:-

94 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
f Boolean To finalise the output
value.
a String To declare the string
array.
i int To execute the loop.
s String To store the search
element.
ub int To determine the
upperbound of the
array.
lb Iint To determine the
lowerbound of the
array.

95 | Page
mid int To determine the
middle of the array.

Program 22:-

/*WAP to enter any no. and check whether it is a unique

no. or not.*/

import java.util.*;

class UniqueNumber

public void display(int n)

String a=Integer.toString(n);

int l=a.length();

int x[]=new int[l];

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)

System.out.println(n+" is a Unique Number!");

else

System.out.println(n+" is not a Unique Number!");

97 | Page
}

Input and Output:-

98 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
n int To store the original
number.
a String To convert number
into string.
l int To determine the
length of the string.
x int To declare the integer

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:-

/*. WAP to enter n positive integers from the user and

display each integer with its reverse. The program should

terminate if the user enters 0.*/

import java.util.Scanner;

class ReverseNumber

100 | Page
public void display()

int num=0;

int reversenum =0;

System.out.println("Input your number and press enter: ");

Scanner in = new Scanner(System.in);

num = in.nextInt();

while( num != 0 )

reversenum = reversenum * 10;

reversenum = reversenum + num%10;

num = num/10;

System.out.println("Reverse of input number is: "+reversenum);

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:-

/* Create a (3x3) array and find the sum of the lengths of

the left and right diagonals separately.*/

import java.util.*;

public class diagonalsum

public void display()

int[][] matrix = {{1, 2, 3},{4, 5, 6},{7, 8, 9}};

int l = 0;

int r= 0;

for (int i = 0; i < matrix.length; i++)

l += matrix[i][i];

r += matrix[i][matrix.length - 1 - i];

System.out.println("Left Diagonal Sum: " + l);

System.out.println("Right Diagonal Sum: " + r);

105 | Page
Input and output:-

106 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
matrix int To store the matrix
given by the user.
l int To store the left
diagonal lsum.
r int To store the right
diagonal sum.

107 | Page
Program 25:-

/*WAP that encodes a word into Piglatin.*/

import java.util.*;

class Piglatin

public void disp(String a)

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
}

Input and Output:-

109 | Page
Variable Description:-

VARIABLE NAME VARIABLE TYPE VARIABLE


DESCRIPTION
a String To store the main
string.
l int To determine the
length of the string.
i int To execute the outer
loop and to help the
substring while
printing.
ch char To extract a character
from the string.

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

You might also like