Program for Sum of Digits

Posted by Somesh Shinde On Wednesday, 29 June 2016 0 comments
Sum of Digits Logic: 513 -> 5+1+3=9 nresnsum 5130 513%1033 513/10513 51%1014 51/1054 5%1059 5/1009 ProgramOutput //Note: Scanner class work with JDK1.5 or above import java.util.*; class SumDigits { public static void main(String args[]) { int n, res; Scanner scan= new Scanner(System.in); System.out.println("Please Enter No.: "); n1=scan.nextInt(); while(n>0) ...
READ MORE

Write a program to find whether no. is palindrome or not.

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Write a program to find whether no. is palindrome or not. class Palindrome{      public static void main(String args[]){          int num = Integer.parseInt(args[0]);          int n = num; //used at last time check          int...
READ MORE

Write a program to find whether given no. is Armstrong or not.

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Write a program to find whether given no. is Armstrong or not. /*   Example :            Input - 153            Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no.    */ class Armstrong{      public static void main(String...
READ MORE

Write a program to Display Invert Triangle.

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Write a program to Display Invert Triangle. /*  Example:           Input - 5           Output :           5 5 5 5 5           4 4 4 4           3...
READ MORE

Write a program to generate a Triangle.

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Write a program to generate a Triangle. /*   eg:   1   2 2   3 3 3   4 4 4 4    and so on as per user given number */ class Triangle{       public static void main(String args[]){           int num = Integer.parseInt(args[0]);           for(int...
READ MORE

Biggest of 3 Numbers using Logical Operators

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Biggest of 3 Numbers using Logical Operators Program Output //Note: Scanner class work with JDK1.5 or aboveimport java.util.*;class Biggest3{ public static void main(String args[]) { int n1, n2, n3, big; Scanner scan= new Scanner(System.in); System.out.println("Please Enter No 1: "); n1=scan.nextInt(); System.out.println("Please Enter No 2: "); n2=scan.nextInt(); ...
READ MORE

Program For Factorial Numbers

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Program For Factorial Numbers Logic: Factorial of 5 = 5 x 4 x 3 x 2 x 1 prodnprod prod*n 155 5420 20360 602120 1201120 ProgramOutput //Note: Scanner class work with JDK1.5 or above import java.util.*; class Factorial { public static void main(String args[]) { int n, i, prod=1; Scanner scan= new Scanner(System.in); System.out.println("Please Enter a No."); ...
READ MORE

Program For Fibonacci Series

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Fibonacci Series ( 1 1 2 3 5 8 13...) Logic: Sum of previous two numbers will give us next number. prevnextsum shifted to prevshifted to next 112 123 235 358 5813 813... 13...... prev will give you fibonacci series ProgramOutput class Fibonacci { public static void main(String args[]) { int prev, next, sum, n; prev=next=1 for(n=1;n<=10;n++) ...
READ MORE

Finding Prime Numbers

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Prime Number Logic: Prime Number are divisible by itself only. Not divisible by any NumberDivisible by 2 ...no need to check furtherDivisible by 3 ...no need to check further 7%2=17%3=17%4=37%5=27%6=18%2=08%3=8%4=8%5=8%6=8%7=9%2=19%3=09%49%59%69%79%8 Numbers are not divisible by more than half of the number No need to check upto 6 check upto 3 only No need to check upto...
READ MORE

Difference between Post Increment (n++) and Pre Increment (++n)

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Difference between Post Increment (n++) and Pre Increment (++n) Post Increment (n++): It increases the value of variable by 1 after execution of the statement. Pre Increment (++n): It increases the value of variable by 1 before execution of the statement. ProgramOutput class Demo { public static void main(String args[]) { int n=10; System.out.println(n); System.out.println(n++); ...
READ MORE

Difference between BufferedReader and Scanner class

Posted by Somesh Shinde On Tuesday, 28 June 2016 1 comments
Difference between BufferedReader and Scanner class Even though both BufferedReader and Scanner can read a file or user input from command prompt in Java, there some significant differences between them. One of the main difference between BufferedReader and Scanner class...
READ MORE

Setting of JAVA_HOME and PATH in Linux

Posted by Somesh Shinde On Tuesday, 28 June 2016 0 comments
Setting of JAVA_HOME and PATH in Linux The JAVA_HOME environment variable points to the JDK installation directory and used by many Java tools and applications like Eclipse, Maven, ANT, Tomcat etc. to figure out Java executables as they need Java for running. Unfortunately,...
READ MORE
Page 1 of 131234567Next