Witshaper is the Professional (Computing Skills, English Learning and Soft Skills) Skill Development Training Center. We provide Professional IT Courses and Soft Skill Training in Dehradun to Students, Employees and organization. Who wish to pursue a career in IT Technology. Witshaper is led by a motivated team of IT experts and Soft Skill Professionals. We provide high quality trainings. Our Emphasis is on giving the practical knowledge to the students, so that they will get to know in depth and never forget what they opt, we provide to the students real learning environment. Witshaper prepares students and professionals to be the part of this growing industry. Be a part of Witshaper and get your dreams successful

Monday, 18 May 2015

java program to convert letters in string capital to small and vice versa

import java.util.*;
public class Convert
{
public static void main(String args[])
{
System.out.println("Enter the String");
String s1,s2="";
char ch;
Scanner in=new Scanner(System.in);
s1=in.nextLine();
int len=s1.length();
for(int i=0;i<len;i++)
{
ch=s1.charAt(i);
if(ch>=97 && ch <=122)
{
ch-=32;
}
s2=s2+ch;

}
System.out.println("Converted string is:"+s2);
}
}

java program to show the concept of if.......... else if



import java.util.Scanner;
class Year{
  public static void main(String args[]){
     int i;
     System.out.println("Enter the Number of the year");
     Scanner in=new Scanner(System.in);
     i=in.nextInt();

     if(i==1)
       System.out.println("Month is Janurary");

     else if(i==2)
       System.out.println("Month is Feburary");

     else if(i==3)
       System.out.println("Month is March");

     else if(i==4)
       System.out.println("Month is April");

     else if(i==5)
       System.out.println("Month is May");

     else if(i==6)
       System.out.println("Month is June");

     else if(i==7)
       System.out.println("Month is July");

     else if(i==8)
       System.out.println("Month is August");

     else if(i==9)
       System.out.println("Month is September");

     else if(i==10)
       System.out.println("Month is October");

     else if(i==11)
       System.out.println("Month is November");

     else if(i==12)
       System.out.println("Month is December");

     else if(i==0||i>12)
       System.out.println("Enter valid year Number");
  }
}

java program to print Fibonacci series



class Fibonacci{
  public static void main(String args[]){
    System.out.println(" Fibonacci Series ");
    int a1, a2=0, a3=1;
    for(int i=1;i<=20;i++){
     System.out.print(" "+a3+" ");
     a1 = a2;
     a2 = a3;
     a3 = a1 + a2;
     }
  }
}

java program to print the reverse of a given number


public class Combination
{
 public static int reverseNumber(int no)
 {
  int ono=0,rev=0,rem;
  ono=no;
  while(ono!=0)
  {
    rem=ono%10;
    ono/=10;
    rev= (rev*10)+rem;
  }
  return rev;

 }
 public static void main(String[] args){
 Combination.reverseNumber(123);
 }

}

java program to build calculator



import java.util.Scanner;
public class Calculator{
  public static void main(String[] args){
     System.out.println("Enter integers x,y");
     Scanner in = new Scanner(System.in);
     int a,b;
     a = in.nextInt();
     b = in.nextInt();
     int r=0;
     System.out.println(" CALCULATOR ");
     r=a+b;
     System.out.println("a + b = "+r);

     r=a-b;
     System.out.println("a - b = "+r);

     r=a*b;
     System.out.println("a * b = "+r);

     r=a/b;
     System.out.println("a / b = "+r);
  }
}

Write a program to find the largest of 3 numbers.



import java.util.Scanner;

class LargestOfThreeNumbers
{
   public static void main(String args[])
   {
      int x, y, z;
      System.out.println("Enter three integers ");
      Scanner in = new Scanner(System.in);

      x = in.nextInt();
      y = in.nextInt();
      z = in.nextInt();

      if ( x > y && x > z )
         System.out.println("First number is largest.");
      else if ( y > x && y > z )
         System.out.println("Second number is largest.");
      else if ( z > x && z > y )
         System.out.println("Third number is largest.");
      else  
         System.out.println("Entered numbers are not distinct.");
   }
}

java program to add two numbers using different Methods


simple arithmetic using command line argument
1    
      class CommanLine

  {  public static void main(String args[]){  
     int a,b,c=0;
      a=Integer.parseInt(a[0]); 
       b=Integer.parseInt(a[1]); 
     c=a+b;
5 System.out.println("sum is"+c);  
     
7  }  

8  }  

using scanner 

import java.util.Scanner;
class Add_CMD {
  public static void main(String[] args){
   int a,b,c;
   System.out.println("Enter integers ");
   Scanner in = new Scanner(System.in);
   a = in.nextInt();
   b = in.nextInt();
   c=a+b;
   System.out.println("Sum of "  + a+ " and " + b + " is " +c);

  }
}

 using BufferedReader
import java.io.*;
class Arithmatic
{
public static void main(String args[])throws IOException
{
try
{
int a,b,c,ae,nfe;
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
c=a/b;
System.out.println("Result="+c);
}
/*catch(ArithmeticException ae)
{
System.out.println("eror due to"+ ae.getMessage());
}
catch(NumberFormatException nfe)
{
System.out.println("error due to"+ nfe.getMessage());
}*/
catch(Exception nfe)
{
System.out.println("error due to"+ nfe.getMessage());


}

}}