Thursday, 4 August 2011

Arithematic Operation in java

Description of program:
In this section we will get the arithmetic values. First of all, we have to define class named "ArithmaticOperation" . Inside this class we have defined two static variable of  integer type. To assign the value of the numbers define a method main which is overloaded method. This method will take two parameter of integer type. These values will be used in following methods which have declared in this program. Now call the method one by one. To get the values of the two numbers call the overloaded method main() inside main() method. Output will be display on the screen by using println() method of the System class.
Here is the code of this program

class ArithmeticOperator {
  public static int num;
  public static int num1;
  public static void main(int num1, int num2){
  public int Addition(){
  public int Subtract(){
  public int Multiply(){
  public int Divide(){
  public static void main(String args[]){

  ArithmeticOperator arithmeticOperator= new ArithmeticOperator();
  BufferedReader object= new BufferedReader(new InputStreamReader(;
  System.out.println("Enter the Number");
  int addition=arithmeticOperator.Addition();
  int subtract=arithmeticOperator.Subtract();
  int multiply=arithmeticOperator.Multiply();
  int divide=arithmeticOperator.Divide();
  System.out.println("values is num="+ arithmeticOperator.num);
  System.out.println("value is num1="+ arithmeticOperator.num1);
  System.out.println("Addtion is="+ arithmeticOperator.Addition());
  System.out.println("Subtruct is="+ arithmeticOperator.Subtract());
  System.out.println("Multiply is="+ arithmeticOperator.Multiply());  
  System.out.println("Divide is="+ arithmeticOperator.Divide());
  catch(Exception e){}

Post a Comment