0% found this document useful (0 votes)
20 views18 pages

Java Advance - Dxe

The document contains messages from various messaging apps and chat groups. It includes file shares of documents like Java programs and PDFs. There are messages coordinating internships and classes as well as personal messages between individuals making plans and wishing each other greetings.

Uploaded by

Bhuvanesh
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)
20 views18 pages

Java Advance - Dxe

The document contains messages from various messaging apps and chat groups. It includes file shares of documents like Java programs and PDFs. There are messages coordinating internships and classes as well as personal messages between individuals making plans and wishing each other greetings.

Uploaded by

Bhuvanesh
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/ 18

Search or start new chat

Turn on notifications
Get notified of new messages on your computer.Turn on desktop notifications

+91 93454 47904


16:06

This message was deleted


1

Janani
Tuesday

DocScanner Feb 4, 2024 8-11 PM.pdf • 6 pages

NAHTNAJIN
yesterday
Reacted to: "Good morning anna "

Gw
yesterday
https://youtu.be/uUj7VhlZRXs?si=X0JZfmLUHmwfYDb8
16_ Hr Navin ( Official Community Group)
yesterday
~ Hr_Navin (Admin)
: https://tapthe.link/EoC1Hi0Qv Hello Techies Today's Video Out Zoho full stack
developer sharing experience

Devtown JavaScript And React.JS From A To Z#1


yesterday
Community members have changed. Click to view

+91 90251 64247


yesterday
You reacted to: "https://youtube.com/shorts/WDwdXuapdW4?si=F1wAmNW0VaV65ulm"

CSE 2021-25 A JIT


10:07
~ Sithubhuvi
:

data-warehousing-ccs341.pdf • 103 pages


1

+91 97896 68293


12:03

javaprograms.pdf • 35 pages

F16's Association | AU Students


12:04
F16's | AU "CSE" Students

4
~ ✬🇻͢ɪͥ ᴘⷨ ✦͜͡⃝⃝ 🇹𝖆𝖒𝖎𝖑⸙⃟ ⃟ၴ࿐
: Foundation of data science book erukka

Yuva Jit
16:13

JAVA ADVANCED PROGRAM.docx

INTERNSHIP NEXUS
Saturday
~ Abigail
: NOTE We will allot the SLOTS only on first come first serve basis, so hurry up grab
the opportunity of doing internship with your dream company.

TECH Career (MNC'S Training & Internship) @DevTown


Saturday
+91 79058 54868 joined via an invite link

Palanisami
Sunday

Hann

HR Master Class 04
Sunday
+91 6369 782 520 joined via an invite link

Hello techies (official community) - 2


Sunday
~ Hr_Navin (Admin)
: Guys Class Started

Trisha Jit
Sunday
Mm seri

Prithika jit
Tuesday
M ok

Sofia Jit
13:46

javaprograms.pdf • 35 pages
Your personal messages are end-to-end encrypted
Get WhatsApp for Windows

Yuva Jit

Click here to get older messages from your phone.


24/12/2023

77 kB

18:38

Ok da18:52
18:52
11/01/2024

Oii22:35
22:35
Tomorrow saree ah wear pandre22:36
22:36

12/01/2024

Ila da07:59
07:59
Nee08:00
08:00

Katren da08:17
08:17

15/01/2024

இனிய தமிழர் திருநாள் தைப் பொங்கல் நல்வாழ்த்துக்கள் 06:36

06:36

Happy Pongal da 07:05


07:05

TODAY

Forwarded
javaprograms.pdf
35 pages•PDF•253 kB•
12:06

java Basic progaram.docx


DOCX•25 kB•
16:12

java intermediate.docx
DOCX•25 kB•
16:13
JAVA ADVANCED PROGRAM.docx
DOCX•23 kB•
16:13

Type a message
JAVA ADVANCE QUESTIONS

1. Print given number in words

PROGRAM:

public class NumberToWords


{

public void pw(int n, String ch)


{
String one[] = { " ", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", "Nine",
" Ten"," Eleven", " Twelve", " Thirteen", " Fourteen", "Fifteen", " Sixteen", " Seventeen",
" Eighteen"," Nineteen" };

String ten[] = { " ", " ", " Twenty", " Thirty", " Forty", " Fifty", " Sixty", "Seventy", " Eighty",
" Ninety" };

if (n > 19)
{
System.out.print(ten[n / 10] + " " + one[n % 10]);
}
else
{
System.out.print(one[n]);
}
if (n > 0)
System.out.print(ch);
}

public static void main(String[] args)


{

int n=28;
System.out.print(n);
if (n <= 0)
{

System.out.println("Enter numbers greater than 0");


}
else
{
NumberToWords a = new NumberToWords();
a.pw((n / 1000000000), " Hundred");
a.pw((n / 10000000) % 100, " crore");
a.pw(((n / 100000) % 100), " lakh");
a.pw(((n / 1000) % 100), " thousand");
a.pw(((n / 100) % 10), " hundred");
a.pw((n % 100), " ");
}
}
}

Output:
28Twenty Eight

2. Program to print patterns of numbers and stars


***************
******* *******
****** ******
***** *****
**** ****
*** ***
** **
**
**
** **
*** ***
**** ****
***** *****
****** ******
******* *******
***************

PROGRAM:

public class DifferentPatternPrograms1 {


public static void main(String args[]) {
int n,i,j,k,l,m,p,q,r,s; Scanner sc=new Scanner(System.in);
System.out.println("Enter the n values");
n=sc.nextInt(); p=n; q=n; for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
System.out.print("*");
}
for(k=p*2;k<=n;i++)
{
for(j=1;j<=i;j++)
{
System.out.print("*");
}
for(k=q*2-2;k>1;k--)
{
System.out.print(" ");
}
for(m=i;m!=0;m--)
{
if(m==n)
{
continue;
}
System.out.print("*");
}
System.out.println(); q--;
}
}
}

Output
***************
******* *******
****** ******
***** *****
**** ****
*** ***
** **
**
**
** **
*** ***
**** ****
***** *****
****** ******
******* *******
***************

4. Print numbers in pyramid vice


1
212
32123
4321234
543212345

PROGRAM:

import java.util.Scanner;
public class PatternNumberPyramidRev
{
public static void main(String args[])
{
int i, j, k, n, a;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the n values");
n = sc.nextInt();
a = n;
for (i = 1; i <= n; i++)
{
for (j = a; j > 1; j--)
{
System.out.print(" ");
}
for (k = i; k != 0; k--)
{
System.out.print(k);
}
a--;
for (int l = 2; l <= i; l++)
{
System.out.print(l);
}
System.out.println();
}
}
}

Output
Enter the n values5
1
212
32123
4321234
543212345

6. Find largest and smallest number in an array in java

PROGRAM:
public class LargestSmallest
{
public static void main(String[] args)
{
int a[] = new int[] { 23, 34, 13, 64, 72, 90, 10, 15, 9, 27 };
int min = a[0]; // assume first elements as smallest number
int max = a[0]; // assume first elements as largest number
for (int i = 1; i < a.length; i++) // iterate for loop from arrays 1st index (secondelement)
{
if (a[i] > max)
{

max = a[i];
}
if (a[i] < min)
{
min = a[i];
}
}
System.out.println("Largest Number in a given array is : " + max);
System.out.println("Smallest Number in a given array is : " + min);
}
}

Output
Largest Number in a given array is : 90Smallest Number in a given array is : 9

7. Program to find largest and second largest in an array

PROGRAM:

public class LargestAndSecondLargest


{
public static void main(String[] args)
{
int nums[] = { 5, 34, 78, 2, 45, 1, 99, 23 };
int maxOne = 0;
int maxTwo = 0;
for (int i=0;i<nums.length; i++)
{
if (maxOne < nums[i])
{
maxTwo = maxOne;
maxOne = nums[i];
}
else if (maxTwo < nums[i])
{
maxTwo = nums[i];
}
}
System.out.println("Largest Number: " + maxOne);
System.out.println("Second Largest Number: " + maxTwo);
}
}

Output
Largest Number: 99Second Largest Number: 78

8. Program to remove duplicate element in an array

PROGRAM:

public class RemoveDuplicateElements


{
public static int[] removeDuplicates(int[] input)
{
int j = 0;
int i = 1;
// return if the array length is less than 2
if (input.length < 2)
{
return input;
}
while (i < input.length)
{
if (input[i] == input[j])
{
i++;
}

else
{
input[++j] = input[i++];
}
}
int[] output = new int[j + 1];
for (int k = 0; k < output.length; k++)
{
output[k] = input[k];
}
return output;
}
public static void main(String a[])
{
int[] input1 = { 2, 3, 6, 6, 8, 9, 10, 10, 10, 12, 12 };
int[] output = removeDuplicates(input1);
System.out.print("Input Elements: \n");
for (int i : input1)
{
System.out.print(i + " ");
}
System.out.print("\nOutput Elements: \n");
for (int i : output)
{
System.out.print(i + " ");
}
}
}

Output
Input Elements:
2 3 6 8 9 10 12 10 10 12 12
Output Elements:
2 3 6 8 9 10 12

9. Program to add two matrix

PROGRAM:

class MatrixAddition
{
public static void main(String args[])
{
int[][] a = new int[][] { { 1, 2, 3},{ 4, 5, 6},{ 7, 8, 9} };

int[][] b = new int[][] { { 10, 11, 12},{ 13, 14, 15},{ 16, 17, 18} };
int[][] c = new int[3][3];
if(a.length == b.length && a[0].length == b[0].length)
{
for(int i = 0;i < a.length;i++)
{
for(int j = 0;j < a[i].length;j++)
{
c[i][j] = a[i][j] + b[i][j];
}
}
}
else
{
System.out.println("'A' and 'B' Matrix are not SAME");
return;
}
System.out.println("The Matrix 'A' Value:");
for(int i = 0;i < a.length;i++)
{
for(int j = 0;j < a[i].length;j++)
{
System.out.print(a[i][j] + " ");
}
System.out.println();
}

System.out.println("The Matrix 'B' Value:");


for(int i = 0;i < a.length;i++)
{
for(int j = 0;j < a[i].length;j++)
{
System.out.print(b[i][j]+ " ");
}
System.out.println();
}
System.out.println("The Addition Matrix of 'A' and 'B' Value:");
for(int i = 0;i < a.length;i++)
{
for(int j = 0;j < a[i].length;j++)
{
System.out.print(c[i][j] + " ");
}
System.out.println();
}
}
}

Output
The Matrix 'A' Value:
123
456
789
The Matrix 'B' Value:
10 11 12 13 14 15
16 17 18
The Addition Matrix of 'A' and 'B' Value:
11 13 15 17 19 21
23 25 27

10. Program to check given matrix is diagonal matrix

PROGRAM:
class DiagonalMatrix
{
public static void main(String args[])
{
int[][] a = new int[][] { { 1, 0, 1},{ 0, 3, 0},{ 0, 0, 3} };
boolean setValue = true;
abc: for(int i = 0;i < a.length;i++)
{
for(int j = 0;j < a[i].length;j++)
{

if(i == j)
{
if(a[i][j] == 0)
{
setValue = false;
break abc;
}
}
else if(a[i][j] != 0)
{
setValue = false;
break abc;
}
}
}

System.out.println("The Given Matrix Value:");


for(int i = 0;i < a.length;i++)
{
for(int j = 0;j < a[i].length;j++)
{
System.out.print(a[i][j] + " ");
}
System.out.println();
}

if(setValue == true)
{
System.out.println("The Given Matrix is a Diagonal Matrix");
}
else
{
System.out.println("The Given Matrix is not a Diagonal Matrix");
}
}
}
Output
The Given Matrix Value:
101
030
003
The Given Matrix is not a Diagonal Matrix

11. Program to count each words and total number of words in given string

PROGRAM:

import java.io.IOException;

public class FindTtalCountWords


{

public static void main(String args[]) throws IOException


{
countWords("apple banna apple fruit fruit apple hello hi hi hello hi");

static void countWords(String st)


{
String[] words = st.split("\\s");
int[] fr = new int[words.length];
for (int i = 0; i < fr.length; i++)
fr[i] = 0;
for (int i = 0; i < words.length; i++)
{
for (int j = 0; j < words.length; j++)
{
if (words[i].equals(words[j]))
{

fr[i]++;

}
}
}

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


{
for (int j = 0; j < words.length; j++)
{
if (words[i].equals(words[j]))
{
if (i != j)
{
words[i] = "";
}
}
}
}

int total = 0;
System.out.println("Words and words count:");
for (int i = 0; i < words.length; i++)
{
if (words[i] != "")
{

System.out.println(words[i] + "=" + fr[i]);

total += fr[i];

}
}
System.out.println("Total words counted: " + total);
}
}

Output
Words and words count:
banna=1
fruit=2
apple=3
hello=2
hi=3
Total words counted: 11
12. Program to find difference of minimum and maximum numbers of array in java

PROGRAM:

// Java program to find minimum difference


// of maximum and minimum of K number.
import java.util.*;

class GFG {

// Return minimum difference of


// maximum and minimum of k
// elements of arr[0..n-1].
static int minDiff(int arr[], int n, int k) {
int result = Integer.MAX_VALUE;

// Sorting the array.


Arrays.sort(arr);

// Find minimum value among


// all K size subarray.
for (int i = 0; i <= n - k; i++)
result = Math.min(result, arr[i + k - 1] - arr[i]);

return result;
}

// Driver code
public static void main(String[] args) {
int arr[] = {10, 100, 300, 200, 1000, 20, 30};
int n = arr.length;
int k = 3;

System.out.println(minDiff(arr, n, k));
}
}

// This code is contributed by Anant Agarwal.

Output
20

You might also like