Wednesday, February 19

Program For Adding Value to Array using Java



Hi ALL,

Here I wrote a program for Adding Value to Array  Using Java.


package Arrays;



/**
 *
 * @author Balamurugan M
 */
public class Array1 {
    public static void main(String arg[]){
        int[] num=new int[5];
        for(int i=1;i<num.length;i++){
            num[i]=i+num[i-1];
           
        }
        num[0]=num[1]+num[4];
        for(int j=0; j<num.length;j++)
        System.out.println("array value "+num[j]);
       
    }  
   
}

Tuesday, February 18

Finding Area of a Circle in Given Radius Using Java



Hi ALL,

Here I wrote a program for Finding Area of a Circle in Given Radius Using Java.


/**
 *
 * @author Balamurgan M
 */
public class area1 {
    public static void main(String arg[]){
        double radius;
        double area;
        System.out.println(" Enter the size of the radius: \t ");
        Scanner in=new Scanner(System.in);
        radius=in.nextDouble();
        area=radius*radius*3.14;
        System.out.println("The area of the Circle is "+area +" the radius of "
                + "circle is " +radius);
    }
}

Simple Program for Relational Operator And Conditional Operator in java



Hi ALL,

Here I wrote a program for Relational Operator And Conditional Operator in java.

 /**
 *
 * @author Balamurgan M
 */
public class AndORoperator {
    public static void main(String arg[]){
        int x=1;
        int y=1;
        int z=1;
        if((x>1)&(x++ <10))
            System.out.println(" x value "+x);
        if((1>y)&&(1> y++))
            System.out.println(" y value "+y);
         if((1==z)|(10> z++))
            System.out.println(" z value "+z);
    }
   
}

Income Tax calculation using If Else Functionality in Java



Hi ALL,

Here I wrote a program for simple Income Tax calculation using If Else Functionality in Java.


/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;

public class AmericanTaxCalc {
    public static void main(String arg[]){
        System.out.println("US federal person income tax");
        System.out.println("Please fill your status example \n 0.Single \n 1.Married "
                + "Filling Joinly \n 2.Married filling separatly \n 3.Head of household");
        Scanner in=new Scanner(System.in);
        int status=in.nextInt();
        if(status == 0){
            System.out.println("Please enter your annual income :\t$");
            int Aincome=in.nextInt();
            if(Aincome<8350)
                System.out.println(" Your tax amt is : $"+(Aincome*10)/100);
            else if((Aincome>8351)&&(Aincome<=33950))
                 System.out.println(" Your tax amt is : $"+(Aincome*15)/100);
            else if((Aincome>33951)&&(Aincome<=82250))
                 System.out.println(" Your tax amt is : $"+(Aincome*25)/100);
            else if((Aincome>82251)&&(Aincome<=171550))
                 System.out.println(" Your tax amt is : $"+(Aincome*28)/100);
            else if((Aincome>171551)&&(Aincome<=372950))
                 System.out.println(" Your tax amt is : $"+(Aincome*33)/100);
           else
                System.out.println(" Your tax amt is : $"+(Aincome*35)/100);
        }else if(status ==1){
            System.out.println("Please enter your annual income :\t$");
            int Aincome=in.nextInt();
            if(Aincome<16700)
                System.out.println(" Your tax amt is : $"+(Aincome*10)/100);
            else if((Aincome>16701)&&(Aincome<=67900))
                 System.out.println(" Your tax amt is : $"+(Aincome*15)/100);
            else if((Aincome>67901)&&(Aincome<=137050))
                 System.out.println(" Your tax amt is : $"+(Aincome*25)/100);
            else if((Aincome>137051)&&(Aincome<=208850))
                 System.out.println(" Your tax amt is : $"+(Aincome*28)/100);
            else if((Aincome>208851)&&(Aincome<=372950))
                 System.out.println(" Your tax amt is : $"+(Aincome*33)/100);
           else
                System.out.println(" Your tax amt is : $"+(Aincome*35)/100);
           
        }else if(status ==2){
            System.out.println("Please enter your annual income :\t$");
            int Aincome=in.nextInt();
            if(Aincome<8350)
                System.out.println(" Your tax amt is : $"+(Aincome*10)/100);
            else if((Aincome>8351)&&(Aincome<=33950))
                 System.out.println(" Your tax amt is : $"+(Aincome*15)/100);
            else if((Aincome>33951)&&(Aincome<=68525))
                 System.out.println(" Your tax amt is : $"+(Aincome*25)/100);
            else if((Aincome>68526)&&(Aincome<=104425))
                 System.out.println(" Your tax amt is : $"+(Aincome*28)/100);
            else if((Aincome>104426)&&(Aincome<=186475))
                 System.out.println(" Your tax amt is : $"+(Aincome*33)/100);
           else
                System.out.println(" Your tax amt is : $"+(Aincome*35)/100);
           
        }else if(status ==3){
             System.out.println("Please enter your annual income :\t$");
            int Aincome=in.nextInt();
            if(Aincome<11950)
                System.out.println(" Your tax amt is : $"+(Aincome*10)/100);
            else if((Aincome>11951)&&(Aincome<=45550))
                 System.out.println(" Your tax amt is : $"+(Aincome*15)/100);
            else if((Aincome>45551)&&(Aincome<=117450))
                 System.out.println(" Your tax amt is : $"+(Aincome*25)/100);
            else if((Aincome>117451)&&(Aincome<=190200))
                 System.out.println(" Your tax amt is : $"+(Aincome*28)/100);
            else if((Aincome>190201)&&(Aincome<=372950))
                 System.out.println(" Your tax amt is : $"+(Aincome*33)/100);
           else
                System.out.println(" Your tax amt is : $"+(Aincome*35)/100);
           
        }else
            System.out.println("You are entered wrong input");
       
       
    }
   
}

Example program Using Void Method in java



Hi ALL,

Here I wrote a program for Void Method in java.

/**
 *
 * @author Balamurgan M
 */
public class voidMethod {
    public static void main(String arg[]){
        System.out.println(" Return void method ");
        System.out.println(" Test void method "+nprintln("welcome to java",5));
    }
    public static void nprintln(String msg,int n){
        for(int i=0;i<n;i++)
        System.out.println("meassage : "+msg +"  value "+n);
    }
}

Interest Fees Doubled Program in java



Hi ALL,

Here I wrote a program for Interest Fees Doubled Program  in java.

/**
 *
 * @author Balamurgan M
 */
public class TutionFeesDoubled {
   public static void main(String arg[]){
       System.out.println(" Tution fee calcualtion");
       int fee=10000;
       int year=1;
       int n=100;
       int amt=0;
       for(int i=1;i<=n;i++)
       {
           amt+=((fee*7)/100);
         //  System.out.println("amt "+amt);
           if(amt>=fee){
               System.out.println("Year to doubled the amount "+i);
               break;
           }
       }
   }
}

Sentinel Value using Break point in Java



Hi ALL,

Here I wrote a program for Sentinel Value using Break point  in java Example 2.

/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;
public class SentinelValue {
    public static void main(String arg[]){
        System.out.println("Sentinel Value");
        Scanner in=new Scanner(System.in);
        System.out.println(" enter the break point number ");
        int breakPoint=in.nextInt();
        for (int i=0;i<5000;i++){
            System.out.println(i);
            if(i==breakPoint)
                break;
           
        }
        System.out.println("break point is worked");
    }
}

Sentinel Value Generation in Java



Hi ALL,

Here I wrote a program for Sentinel Value Generation in java Example 1.


/**
 *
 * @author Balamurgan M
 */
public class sentinelValue1 {
    public static void main(String arg[]){
        System.out.println(" Senthinel value 1");
        double x=1; double sum=0;
        while(x!=0){
            sum +=x;
            x -=0.1;
        }
        System.out.println(" X value "+ x +" Sum Value "+sum);
    }
}

Random Number generation Using Java



Hi ALL,

Here I wrote a program for Random Number generation Using java.


/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;

public class RandomNumber {
    public static void main(String arg[]){
        System.out.println("Enter the number ");
        Scanner in=new Scanner(System.in);
        for(int i=0;i<10;i++){
            int num=in.nextInt();
            System.out.println(num);
        }
    }

}

Finding Prime Number Series Using Static Method in Java.



Hi ALL,

Here I wrote a program for Finding Prime Number Series Using Static Method in java.

/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;
public class PrimeNumber {
    public static void main(String arg[]){
        System.out.println(" Prime Number Serious ");
      
       Scanner s = new Scanner(System.in);
       System.out.print("Enter the first number number : ");
       int start = s.nextInt();
       System.out.print("Enter the second number number : ");
       int end = s.nextInt();
       System.out.println("List of prime numbers between " + start + " and " + end);
       for (int i = start; i <= end; i++) {
           if (isPrime(i)) {
               System.out.println(i);
           }
       }
   }

   public static boolean isPrime(int n) {
       if (n <= 1) {
           return false;
       }
       for (int i = 2; i < Math.sqrt(n); i++) {
           if (n % i == 0) {
               return false;
           }
       }
       return true;
   }
}

Finding Common Divisor using Conditional Operators in Java



Hi ALL,

Here I wrote a program for Finding Common Divisor using Conditional Operators in Java.




/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;

public class OperatorExample {
    public static void main(String arg[]){
        System.out.println("Please enter number :");
        Scanner in=new Scanner(System.in);
        int num=in.nextInt();
        if(((num %2 )==0)&&((num%3)==0))
            System.out.println(" Given number divisional by 2 and 3 "+num);
        else if(((num %2 )==0)||((num%3)==0))
             System.out.println(" Given number divisional by 2 or 3 "+num);
        else if (!((num %2 )==0)||((num%3)==0))
                System.out.println(" Given number Not divisional by 2  3 "+num);
    }
}

Sum of Number for given limit in Java.



Hi ALL,

Here I wrote a program for  Sum of Number for given limit in java.

/**
 *
 * @author Balamurgan M
 */
public class method1 {
    public static void main(String arg[]){
        System.out.println(" Sum of Number for given limit ");
        System.out.println(" Sum of 1 to 10 "+sum(1,10));
         System.out.println(" Sum of 1 to 10 "+sum(25,35));
          System.out.println(" Sum of 1 to 10 "+sum(40,50));
       
    }

    private static int sum(int num1,int num2){
        int sum_1=0;     
        for(int i=num1;i<=num2;i++)
            sum_1 +=i;
       return sum_1;
    }
}

Finding Biggest Number in Math Functionality (MAX) Using Java



Hi ALL,

Here I wrote a program for Finding Biggest Number in Math Functionality (MAX) Using java.

/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;
public class MaxMethod {
    public static void main(String arg[]){
        System.out.println(" Max of given number ");
        Scanner in=new Scanner(System.in);
        int m=in.nextInt();
        int n=in.nextInt();
        System.out.println(" Max of number : "+max(m,n));
    }
    public static int max(int a,int b){
        int value;
        if(a>b)
            value=a;
        else
            value=b;
                   
        return value;
    }
   
}

Solving Subtraction Issue in Maths Using Java



Hi ALL,

Here I wrote a program for Solving Subtraction Issue in Maths Using java.

/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;

public class MathExample {
    public static void main(String arg[]){
        System.out.println("Enter the I J value ");
        Scanner in=new Scanner(System.in);
        int i=in.nextInt();
        int j=in.nextInt();
        if(i>j){
            System.out.println(" Please Solve simple subtraction issue ");
        System.out.println(i+"-"+j+"= ?");
        int uans=in.nextInt();
        int ans=i-j;
        if(ans==uans)
            System.out.println(" Answer is corrct" +ans);
        else
            System.out.println(" Answer is Incorrect :-(");
        }else
            System.out.println(" Given value is incorrct");
           
    }
   
}

Finding Leap Year in Java



Hi ALL,

Here I wrote a program for Finding Leap Year in java.



/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;

public class LeapYear {
public static void main(String arg[]){
    System.out.println("Plase enter the year");
    Scanner in=new Scanner(System.in);
    int year=in.nextInt();
    if((((year%4)==0)&&(year%100)!=0)||(year%400)==0)
       System.out.println("It is leap year "+year);
    else
        System.out.println(" It is not a Leap Year "+year);
}   
}

Integer Numeric Calculation Magic in Java



Hi ALL,

Here I wrote a program for Integer Numeric Calculation Magic in java.


/**
 *
 * @author Balamurgan M
 */

import java.util.Scanner;
public class intnumbercalc {
    public static void main(String arg[]){
        System.out.println(1.0 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1);
System.out.println(1.0 - 0.9);
        System.out.println("Enter any numeric value\t");
        Scanner in=new Scanner(System.in);
       
byte x=in.nextByte();
        System.out.println("x value"+x);
    }
}

Magic between Increment and Decrement operators in Java



Hi ALL,

Here I wrote a program for Magic between Increment and Decrement operators in java.


/**
 *
 * @author Balamurgan M
 */
public class incerment {
    public static void main(String arg[]){
        int i=10;
        int x=10 * i++;
        System.out.println("i value  " +i+ " x value "+x);
        int y=10;
        x=10 * ++y;
        System.out.println("y value "+ y +" x value "+x);
       
        System.out.println("Decrement operation ");
        int z=10;
        x=10 * z--;
        System.out.println("Z value "+ z +" x value "+x);
       
        int j=10;
        x=10 * --j;
        System.out.println("Z value "+ z +" x value "+x);
      
        i=10;
        int k=i++ +1;
        System.out.println("K value "+k);
    }
   
}

Finding Greatest Common Divisor in Java



Hi ALL,

Here I wrote a program for Greatest Common Divisor in java.


/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;
public class GreatestCommonDivisor {
    public static void main(String arg[]){
        Scanner in=new Scanner(System.in);
        System.out.println(" Greatest Common Divisor");
        System.out.println(" Enter the number1 and number2 ");
        int num1=in.nextInt();
        int num2=in.nextInt();
        int max;
        int count=0;
        if(num1>num2)
           max=num1;
        else
            max=num2;
        for(int i=1;i<=max;i++){
            if((num1 % i)==0 && (num2 %i)==0){
               // System.out.println("count"+count +" i value "+i);  
                count =i;
            }
         
                
        }
        System.out.println("Common divisor is "+count);
    }
   
}

Finding Biggest Number among Three Numbers in Java



Hi ALL,

Here I wrote a program for Finding Biggest Number among Three Numbers  in java.


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;
public class GraterNum {
    public static void main(String arg[]){
        System.out.println("Enter the I J K value " );
        Scanner in=new Scanner(System.in);
       
        int i=in.nextInt();
        int j=in.nextInt();
        int k=in.nextInt();
     if(i>j)
         if(i>k)
                System.out.println(" I is greatest value "+ i);
         else
                System.out.println(" K is Greatest Value "+ k);
     else
           System.out.println(" J is Greatest Value "+ j);
    }
}

FOR loop Functionality in Java



Hi ALL,

Here I wrote a program for  FOR Loop Functionality in java.



/**
 *
 * @author Balamurgan M
 */
public class forLopp {
    public static void main(String arg[]){
    for(;;)
            System.out.println("Welcome to java");
}
}

Given Number Divided by 5 or 2 in Java





Hi ALL,

Here I wrote a program for Given Number Divided by 5 or 2 in java.



/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;

public class FindNumber {
    public static void main(String arg[]){
        System.out.println("Enter The number :");
        Scanner in=new Scanner(System.in);
        int num=in.nextInt();
        if(num%5 ==0)
            System.out.println(" Given number is HIFIVE "+num);
        if(num%2 ==0)
            System.out.println(" Given number id HIEVEN " +num);
    }
}

Fahrenheit to Celsius Program in java



Hi ALL,

Here I wrote a program for simple Fahrenheit  to Celsius in java.



/**
 *
 * @author Balamurgan M
 */

import java.util.Scanner;
public class fahrenheait_to_c {
    public static void main(String arg[]){
        System.out.println("Enter the Fahrunheait value \t");
        Scanner in=new Scanner(System.in);
        int f=in.nextInt();
        double c=(5/9);
                c *=(f-32);
        System.out.println("Celcius value is "+ c);
        System.out.println(System.currentTimeMillis());
    }
}

Backup files to google drive using PHP coding

 Dear All, To backup files to Google Drive using PHP coding, you can use the Google Drive API and the Google Client Library for PHP. Here...