• Complain

Pataskar Aniket. - 100+ Java Programs with Output: Useful collection of Java Programs

Here you can read online Pataskar Aniket. - 100+ Java Programs with Output: Useful collection of Java Programs full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    100+ Java Programs with Output: Useful collection of Java Programs
  • Author:
  • Genre:
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

100+ Java Programs with Output: Useful collection of Java Programs: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "100+ Java Programs with Output: Useful collection of Java Programs" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Amazon Digital Services LLC, 2016. 116 p. ASIN: B01B53SJIAFeatures:
100+ programs with Outputs,
100+ Java Interview Questions - more to be added soon!,
Now with Search Feature to easily find the Program you want from a huge list of programs,
Long press to copy the Program Text.
Now Added upto 30+ Java specific Interview Questions, More Coming Soon!
Here is a list of Programs with Outputs :-
Armstrong Number
Binary Search
Bubble Sort
Fahrenheit To Celsius
Fibonacci Series
Palindrome
Printing Prime Numbers
Calculate Circle Area Using Java Example
Operators
Threads
Formatting
Java Calendar Related Programs
Simple Date Format
Strings
and Many other Programs
A lot More to come...

Pataskar Aniket.: author's other books


Who wrote 100+ Java Programs with Output: Useful collection of Java Programs? Find out the surname, the name of the author of the book and a list of all author's works by series.

100+ Java Programs with Output: Useful collection of Java Programs — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "100+ Java Programs with Output: Useful collection of Java Programs" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
By Aniket Pataskar INDEX 1 Hello World example3 2 Add two matrices 4 3 - photo 1
By : Aniket Pataskar
INDEX
1. Hello World example3
2. Add two matrices 4
3. Armstrong number7
4. Binary Search11
5. Bubble sort14
6. Command line arguments17


11. Java Programs part 1 28


1. Hello World example

class HelloWorld {
public static void main ( String args []) {

System . out . println ( Hello World" ) ; }
}

"Hello World" is passed as an argument to printlnmethod, you can print whatever you want. There is alsoa print method which doesn't takes the cursor tobeginning of next line as println does. System is a class,out is object of PrintStream class and println is themethod.

Output of program:100 Java Programs with Output Useful collection of Java Programs - image 22 Add Two Matrices import javautilScanner class AddTwoMatrix - photo 3
2. Add Two Matrices

import java.util.Scanner ;
class AddTwoMatrix {
public static void main ( String args []) {
Scanner in = new Scanner ( System . in ) ;

System . out . println ( "Enter
the number of rows and
columns of matrix" ) ;

m = in. nextInt () ;
n = in. nextInt () ;
int first [][] = new int [ m ][ n ] ;

int second [][] = new int [ m ][ n ] ; int sum [][] = new int [ m ][ n ] ;

System . out . println ( "Enter
the elements of first
matrix" ) ;
for ( c = ; c < m ; c ++ )

for ( d = ; d < n ; d ++ )
int m, n, c, d ;
first [ c ][ d ] = in.nextInt () ;

System . out . println ( Enter the elements of second matrix" ) ;
for ( c = ; c < m ; c ++ )

for ( d = ; d < n ; d ++ )
second [ c ][ d ] = in.nextInt () ; for ( c = ; c < m ; c ++ )
for ( d = ; d < n ; d ++ )

sum [ c ][ d ] = first [ c ][ d ] + second [ c ]
[ d ] ; //replace '+' with '-' to subtract matrices

System . out . println ( "Sum of entered matrices:-" ) ;
for ( c = ; c < m ; c ++ )

{
for ( d = ; d < n ; d ++ )
System . out . print ( sum [ c ][ d ] + " \t " ) ;

System . out . println () ;
}
}

}
Output of program: This code adds two matrix you can modify it to add anynumber of matrices You - photo 4

This code adds two matrix, you can modify it to add anynumber of matrices. You can create a Matrix class andcreate it's objects and then create an add method which sum the objects, then you can add any number ofmatrices by repeatedly calling the method using a loop.

3. Binary Search

import java.util.Scanner ;
class BinarySearch {
public static void main ( String args []) {

int c, first, last, middle, n, search, array [] ;
Scanner in = new Scanner ( System . in ) ; System . out . println ( "Enter
number of elements" ) ;
n = in. nextInt () ;
array = new int [ n ] ;
System . out . println ( "Enter "
+ n + " integers" ) ;
for ( c = ; c < n ; c ++ ) array [ c ] =

in. nextInt () ;
System . out . println ( "Enter
value to find" ) ;

search = in. nextInt () ;
first = ; last = n - ;
middle = ( first + last ) /
;

if ( array [ middle ] < search ) first = middle + ; else if

( array [ middle ] == search ){
System . out . println ( search +
" found at location " +
( middle + ) + "." ) ;
break ; }

else

last = middle - ;
middle = ( first +
last ) / ;
}
if ( first > last )

System . out . println ( search + " is not present in the list. \n " ) ;

}
}
while ( first <= last ) {

Output of program: Other methods of searching are Linear search andHashing There is a - photo 5

Other methods of searching are Linear search andHashing. There is a binarySearch method in Arrays classwhich can also be used.

import java.util.Arrays ;
class BS {
public static void main ( String args [])

{
char characters [] =

{ 'a' , 'b' , 'c' , 'd' , 'e' } ;
System . out . println ( Arrays . bi
narySearch ( characters,
'a' )) ;
System . out . println ( Arrays . bi
narySearch ( characters,
'p' )) ;
}

}

binarySearch method returns the location if a match occurs otherwise - (x+1) where x is the no. of elements inthe array, For example in the second case above when pis not present in characters array the returned value willbe -6.

4. Armstrong number

This java program checks if a number is Armstrong ornot. Armstrong number is a number which is equal tosum of digits raise to the power total number of digits inthe number. Some Armstrong numbers are: 0, 1, 4, 5, 9,153, 371, 407, 8208 etc.

Java programming code
import java.util.Scanner ;
class ArmstrongNumber {
public static void main ( String args []) {

int n, sum = , temp, remainder, digits = ;
Scanner in = new Scanner ( System . in ) ;

System . out . println ( "Input a number to check if it is an Armstrong number" ) ; n = in. nextInt () ; temp = n ;
// Count number of digits

while ( temp != ) {
% ;
digits ++;

temp = temp / ;
}
temp = n ;
while ( temp != ) {

remainder = temp
sum = sum + power ( remainder, digits ) ;
temp = temp / ;
}
if ( n == sum )

System . out . println ( n + " is an Armstrong number." ) ;
else

System . out . println ( n + " is not an Armstrong number." ) ;
}

static int power ( int n, int r ) { int c, p = ;
for ( c = ; c <= r ; c +
+ )
return p ;
p = p * n ; }
}
Output of program Using one more loop in the above code you can - photo 6 Output of program: Using one more loop in the above code you can generateArmstrong numbers from 1 - photo 7

Using one more loop in the above code you can generateArmstrong numbers from 1 to n(say) or between twointegers (a to b).

5.Bubble sort
Java program to bubble sort: This code sorts numbersinputted by user using Bubble sort algorithm.

Java programming code
import java.util.Scanner ;
class BubbleSort { public static void

main ( String [] args ) { int n, c, d, swap ; Scanner in = new

Scanner ( System . in ) ;
System . out . println ( "Input
number of integers to
sort" ) ;
n = in. nextInt () ; int array [] = new

int [ n ] ; System . out . println ( "Enter " + n + " integers" ) ;
for ( c = ; c < n ; c ++ ) array [ c ] = in. nextInt () ;
for ( c = ; c < ( n - ) ; c ++ ) {

for ( d = ; d < n - c
- ; d ++ ) {
if ( array [ d ] >

array [ d + ]) /* For descending order use < */

{
array [ d ] ;
swap =

array [ d ] =
array [ d + ] ;
array [ d + ] = swap ;
}
} }

System . out . println ( "Sorted
list of numbers" ) ;
for ( c = ; c < n ; c ++ )

System . out . println ( array [ c ])
;
}

}

Complexity of bubble sort is O(n2) which makes it a lessfrequent option for arranging in sorted order whenquantity of numbers is high.
Output of program:

6 Command line arguments class Arguments public static void main String - photo 8Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «100+ Java Programs with Output: Useful collection of Java Programs»

Look at similar books to 100+ Java Programs with Output: Useful collection of Java Programs. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «100+ Java Programs with Output: Useful collection of Java Programs»

Discussion, reviews of the book 100+ Java Programs with Output: Useful collection of Java Programs and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.