Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
The Arithmetic Operators 
 

In this section we will learn how to calculate arithmetic operation. The java programming tutorial provide operators that perform the mathematical values addition, subtraction, multiplication, and division.

 

Java Example Using Arithmetic Operators

                         

In this section we will learn how to calculate arithmetic operation. The java programming tutorial provide operators that perform the mathematical values addition, subtraction, multiplication, and division. 

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

import java.io.*;

class ArithmeticOperator {
  public static int num;
  public static int num1;
  public static void main(int num1, int num2){
    num=num1;
    num1=num2;
  }
  public int Addition(){
    return(num+num1);
  }
  public int Subtract(){
    return(num-num1);
  }
  public int Multiply(){
    return(num*num1);
  }
  public int Divide(){
    return(num/num1);
  }
  public static void main(String args[]){
    try{

    ArithmeticOperator arithmeticOperator= new ArithmeticOperator();
    BufferedReader object= new BufferedReader(new InputStreamReader(System.in));
      System.out.println("Enter the Number");
    arithmeticOperator.num=Integer.parseInt(object.readLine());
    arithmeticOperator.num1=Integer.parseInt(object.readLine());
    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){}
      
    }
  }



 Download this example

                         

» View all related tutorials
Related Tags: c convert io help this program to learn ram ear e il it section li in converting m ps all

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.