add two no in Java

add two no in Java

Java Add Example that accepts two integer from the user and find their sum

View Answers

September 3, 2012 at 1:02 PM

Here is a java example that accepts two integer from the user and find their sum.

import java.util.*;
class AddNumbers
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter first number: ");
        int num1=input.nextInt(); 
        System.out.print("Enter second number: ");
        int num2=input.nextInt();
        int sum=num1+num2;
        System.out.println("Result is: "+sum);
    }
}









Related Tutorials/Questions & Answers:
Add two number in java
Add two number in java In this section you will learn about how to add two number in java. In java adding two number,  first taking the input provided... be added, So two add,  convert these String into numeric type
How to add two numbers in Java?
How to add two numbers in a Java program? In Java you can easily add two number by using the plus (+) operator. The plus operator will add two numbers in Java it will return you int value as sum of two numbers. In real world
Advertisements
Add two big numbers - Java Beginners
Add two big numbers - Java Beginners  Hi, I am beginner in Java and leaned basic concepts of Java. Now I am trying to find example code for adding big numbers in Java. I need basic Java Beginners example. It should easy
Applet for add two numbers
Applet for add two numbers  what is the java applet code for add two...); add(text2); label3 = new Label("Sum of Two Numbers...: "); label1.setBounds(20,20,100,20); add(label1); text1 = new TextField(5
How can you add elements of two arrayLists in java?
How can you add elements of two arrayLists in java?  if you have an arrayList of tempArr = [hi, my, name, is, john] and another arrayList of tempArray2 = [a, b, c, d, e] and you want it to result in newArr = [hi a, my b, name c
how to add two object in a particular file - Java Beginners
how to add two object in a particular file  Hi frend.. I have two arraylist object in which there is some data..............now i want to add these two objects in a particular file using file handling in java....and also
Add two big numbers
Add two big numbers       In this section, you will learn how to add two big numbers...(BigDecimal big): This method is used to add the two BigDecimal numbers. Here
python merge two dictionaries add values
python merge two dictionaries add values  Hi, In Python I have two dictionaries with same keys. I want to merge the two dictionaries and add the values (int values) into the merged dictionary. For example student marks in three
How to add two calendars on the same html page
How to add two calendars on the same html page  I have used the same... use single calendar for a single html page.but while implementing two calendars.... Rest of the code remains same. <html> <head> <title>Java
compare two strings in java
compare two strings in java  How to compare two strings in java...) { System.out.println("The two strings are the same."); } } } Output: The two strings are the same. Description:-Here is an example of comparing two
Add Two Numbers in Java
Add Two Numbers in Java     .... So to add, you have to convert these Strings in numeric type (int... into integer type. Now you can add these values into a sum variable and print
intersection of two java arrays
intersection of two java arrays  I am trying to figure out how to compare two arrays and get the intersection and put this into a third array of the correct size. I know how to copy the two arrays into the third array but am
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new column in table before two column in sql.   Syntax of Alter table: ALTER... named 'employee' having three fields id, name and salary. Now we want to add two
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new column in table before two column in sql.   Syntax of Alter table: ALTER... named 'employee' having three fields id, name and salary. Now we want to add two
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new column in table before two column in sql.   Syntax of Alter table: ALTER... named 'employee' having three fields id, name and salary. Now we want to add two
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new column in table before two column in sql.   Syntax of Alter table: ALTER... named 'employee' having three fields id, name and salary. Now we want to add two
How to concatenate two arrays in Java?
How to concatenate two arrays in Java?  How to concatenate two arrays in Java
java code for swaping two number
java code for swaping two number  how to code for swaping two number without taking third variables
two dimensional - Java Beginners
two dimensional  write a program to create a 3*3 array and print the sum of all the numbers stored in it.  Hi Friend, Try the following code: import java.io.*; import java.util.*; public class matrix
reverse two dimensional arrays in java
reverse two dimensional arrays in java  reverse array elements in two dimensional array such that the last element becomes the first
JavaScript determine add, product of two numbers
JavaScript determine add, product of two numbers In this section, you will learn how to determine addition, multiplication, division and modulus of two numbers. To find this, we have created two textboxes and four button
Difference in two dates - Java Beginners
on that. The thing is, that I need to find the difference between the two dates in JAVA...Difference in two dates  Hello there once again........ Dear Sir... the difference between two dates. public class DateDiffDemo { public static
adding two numbers - Java Beginners
adding two numbers  hii friends....... this is my program...]=Integer.parseInt(in.readLine()); int s=x[1]+y[1]; System.out.println("Sum of two...]; System.out.println("Sum of two no. is:"+s); } } For read more
java code to compare two hash map objects
java code to compare two hash map objects  java code to compare two hash map objects
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
java collision detection between two images
java collision detection between two images  java collision detection between two images
Collision Detection between two images in Java
Collision Detection between two images in Java  Collision Detection between two images in Java
Two- Dimensional Array - Java Beginners
Two- Dimensional Array  I am new in java programming. I am creating a two-dimensional array. This is my code ** class BinaryNumbers { public static void main(String[] args) { //create a two-dimensional array int ROWS = 21
Concatenating two Strings in Java
Concatenating two Strings in Java In this section we will help you, how to concatenate two strings in java. String are sequence of character which is used...=" Java"; str1.concate(str2); In the above code declaring two string str1
how to add the two tables in same row when generating pdf file from jsp - JSP-Servlet
how to add the two tables in same row when generating pdf file from jsp  How to add the two tables in same row one is left side and other is right side please help me.   Hi Friend, Try the following code
write a program that Implement an integrated COM client server to add two numbers.by visuall studio 2010
write a program that Implement an integrated COM client server to add two numbers.by visuall studio 2010  write a program that Implement an integrated COM client server to add two numbers.by visuall studio 2010 if someone can do
Comparing two dates in java
Comparing two dates in java In this example you will learn how to compare two dates in java.  java.util.Date provide a  method to compare two dates... date. The example below compares the two dates. import
two dimansional array - Java Beginners
two dimansional array  Modify the following program so that it computes and prints the tables of powers from 1 to 15.( 1 to 15 to the power 1, Squared, and Cubed: like below) it should look like 1 1 1 2 4 8 3 9 27 and so
How to add BigDecimal in Java?
How to add BigDecimal in Java?  Hi, I have two BigDecimal variables. I want to add these two values. How to add BigDecimal in Java? Thanks   Hello, I will show you how you can add two BigDecimal? Suppose you have
Dividing of two Matrix in Java
Dividing of two Matrix in Java   ...;Here you will learn how to use two matrix array for developing Java program.  The java two dimensional array program is operate the two matrix. Now we
list of all months between two dates in java
list of all months between two dates in java  Hi, I want to get list of all months with year between two dates. How to do this in Java? Thanks...(); System.out.println(date); // Add One Month to get next
list of all months between two dates in java
list of all months between two dates in java  Hi, I want to get list of all months with year between two dates. How to do this in Java? Thanks...(); System.out.println(date); // Add One Month to get next
Java BigDecimal add example
Java BigDecimal add example       In this example working of .add() method is demonstrated in following two constructor forms add(BigDecimal augend) and add(BigDecimal augend
Concatenate Two Strings in java
Concatenate Two Strings in java We are going to describe how to concatenate...) method it means add the two String first-to-end. You can  use anther .... ADS_TO_REPLACE_1 There are two method add of String:- String string3
server with two port - Java Server Faces Questions
server with two port  Hello, want to write two port server socket program using Java, (i.e. single server program which is listening on two ports (say 3122 and 3133) simultaneously. In this program when two different clients
Two dimensional array in java
Two dimensional array in java. In this section you will learn about two-dimensional array in java with an example. As we know that array is a collection of similar data type or it can hold fixed number of value of same type. Two
Multiplication of two polynomials using linked list in java
Multiplication of two polynomials using linked list in java  I am doing a program "Multiplication of two polynomials using linked list in java...() { numC = 0; numE = 0; next = null; } // constructor with two argument public
Sum of two numbers using command line arguments in Java
sum = a+b; Check complete example code at Add Two Numbers in Java. Thanks... to pass two values as parameter from command line and the get in it Java program? The calculate the sum of two numbers using command line arguments in Java
display dates between two dates - Java Beginners
display dates between two dates  hi can any one help me to writing this code, i need to store the dates between to dates so that i can retrive the data from the db using theses dates. its urgent pls tell me as possible
add
Java Program to add two numbers  Java Program to add two numbers  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main
add
How to add two int numbers in Java Example  How to add two int numbers in Java Example  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers
add
Java Example to add two numbers  Java Example to add two numbers  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main
Find L.C.M. of two numbers in Java
Find L.C.M. of two numbers in Java Program In this section, you will learn how to find LCM(Least Common Element) of two integers.The least common multiple... have created a method determineLCM(int a, int b) where we have compared the two
add
add two no in Java  Java Add Example that accepts two integer from the user and find their sum  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers

Ads