PROGRAM TO PRINT EVEN AND ODD NUMBERS

//PROGRAM TO PRINT EVEN AND ODD NUMBERS class evenOdd { public static void main(String args[ ]) { int i; System.out.println(“Even and Odd numbers upto 10 are:”); System.out.println(“Odd numbers are:”); for(i=1;i<=10;i=i+2)   …

PROGRAM TO SWAP TWO NUMBERS – JAVA

//PROGRAM TO SWAP TWO NUMBERS class Swap { public static void main(String a[]) { int x=11,y=7,z; System.out.println(“before swaping the numbers are: x:”+x+” y:”+y); z=x; x=y; y=z; System.out.println(“after swaping the numbers …

PROGRAM TO SHOW THE USE OF INTERFACE

//PROGRAM TO SHOW THE USE OF INTERFACE interface Area { final static float pi=3.14F; float compute(float x, float y); } class Rectangle implements Area { public float compute(float x,float y) …

program to show day of week using switch case

//program to show day of week using switch case. class SwitchWeek { public static void main(String ar[]) { int n=5; switch(n) { case 1: System.out.println(“Sunday”); break; case 2: System.out.println(“Monday”); break; …

PROGRAM TO GENERATE RANDOM NUMBER

//program to generate random number public class RandomNum { public static void main(String args[]) { int rnd=(int)(100*Math.random()); System.out.println(“Random number is: “+rnd); } }

PROGRAM TO FIND PRIME NUMBER – JAVA

//PROGRAM TO FIND PRIME NUMBER class Prime { public static void main(String arg[]) { int n=4,f=0; for(int i=2;i<=n/2;i++) { if(n%i==0) { System.out.println(“The number is not prime”); f=1; break; } } …