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

Wednesday, 20 May 2015

constructor and function example in java

class Employee{
double salary,gross,tax=0;
String name,empid;

public Employee(){
gross=0;
tax=0;
salary=0;
name="null";
empid="null";
}
public Employee(String nme,String eid,double sal){
salary=sal;
empid=eid;
name=nme;
}
public double increase_Salary(double percent){
return salary=(salary+((percent*salary)/100));

}
public double calculate_tax(){

if(salary>=100000&& salary<150000){
tax=(10*(salary/100));
}
else if(salary>=150000){
tax=(20*(salary/100));
}
return tax;

}

public double gross_salary(){
if(salary>=100000&& salary<150000){
gross=(salary-(10*(salary/100)));
}
else if(salary>=150000){
gross=salary-(20*(salary/100));
}
return gross;
}

public void display(){
for (int i=1;i<=12;i++){
if(i==1){
System.out.println(i+" "+name+" "+"JAN"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==2){
System.out.println(i+" "+name+" "+"FEB"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==3){
System.out.println(i+" "+name+" "+"MAR"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==4){
System.out.println(i+" "+name+" "+"APR"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==5){
System.out.println(i+" "+name+" "+"MAY"+" "+empid+" "+salary+" "+(calculate_tax()/12)+" "+(gross_salary()/12)+" "+(increase_Salary(20)/12));
}
if(i==6){
System.out.println(i+" "+name+" "+"JUN"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==7){
System.out.println(i+" "+name+" "+"JUL"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==8){
System.out.println(i+" "+name+" "+"AUG"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==9){
System.out.println(i+" "+name+" "+"SEP"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==10){
System.out.println(i+" "+name+" "+"OCT"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==11){
System.out.println(i+" "+name+" "+"NOV"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
if(i==12){
System.out.println(i+" "+name+" "+"DEC"+" "+empid+" "+(salary/12)+" "+(calculate_tax()/12)+" "+(gross_salary()/12));
}
}
}
public static void main(String[] args){

Employee emp=new Employee("Nikhil Jain","R101",2400000);
emp.display();
}
}

Monday, 18 May 2015

java program to show conversion of string to float ,int and vice versa


1) integer
public class Convert{
public static void main(String[] args){
System.out.println("****Conversion of Int to Integer****");
int i=10;
Integer z= Integer.valueOf(i);
System.out.println("Value of z="+i);
System.out.println("****Conversion of Integer to String****");
String s;
s= Integer.toBinaryString(12);
System.out.println("Value of s is "+s);
System.out.println("****Conversion of Integer to Int****");
Integer y= new Integer(12);
int x= y.intValue();
System.out.println("Value of x"+x);
System.out.println("****Conversion of String to Int****");
double a= Double.parseDouble("123.123");
int k=(int)a;
System.out.println("Value of k="+k);
System.out.println("****Conversion of String to Integer****");
short v= Short.parseShort("10011",2);
Integer b= new Integer(v);
System.out.println("Value of b="+b);
System.out.println("****Conversion of Int to String****");
int e=10;
Integer g= new Integer(e);
String f= Integer.toString(213);
System.out.println("Value of f is "+f);
}
}


2)float


public class Conversion{
public static void main(String[] args){
System.out.println("****Conversion of Float to float****");
float f= new Float("123.23");
System.out.println("Value of f="+f);
System.out.println("****Conversion of Float to String****");
Float g= new Float(123.123);
String y= String.valueOf(g);
System.out.println("Value of y is "+y);
System.out.println("****Conversion of String to Float****");
Float k= Float.valueOf("170.78");
System.out.println("Value of k="+k);
System.out.println("****Conversion of String to float****");
float z= Float.parseFloat("71.11");
System.out.println("Value of z="+z);
System.out.println("****Conversion of float to Float****");
float a=122.24f;
Float x= Float.valueOf(a);
System.out.println("Value of x"+x);
System.out.println("****Conversion of float to String****");
float h=18.45f;
String s= String.valueOf(h);
System.out.println("Value of s is "+s);
}

}

java program to check a letter is present in the string or not

import java.util.*;
public class CheckString
{
public static void main(String args[])
{
String s1;
char s2='a';
int count=0,j=0;
int arr[]=new int[25];
System.out.println("Enter your name");
Scanner in=new Scanner(System.in);
s1=in.nextLine();
int len=s1.length();
for(int i=0;i<len;i++)
{
if(s1.charAt(i)==s2)
{
count++;
arr[j]=i;
j++;
}
}
System.out.println("You name contains\t"+count+" times a \n");
System .out.println("a is present at following locations\n");
for(int k=0;k<j;k++)
{
System.out.println(arr[k]);
}
}
}

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);
 }

}