Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners example that accepts two integer from the user and find their sum
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


jijomon.v
example that accepts two integer from the user and find their sum
1 Answer(s)      2 years and 6 months ago
Posted in : Java Beginners


example that accepts two integer from the user and find their sum


Advertisement
View Answers

September 3, 2012 at 1:03 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:
accept integer from user
accept integer from user  Write an Java application that accepts 100 integer numbers from a user. The input should be in the range of 1-200. Error message needs to be displayed if user entered input which is not in this range
write a program which asks the user for two int values and calculates their sum.
write a program which asks the user for two int values and calculates their sum.  The title says it all, an example is (1,2) > 3
Advertisements
How to find out the friend user between two columns in sql database
How to find out the friend user between two columns in sql database  Hi, Can any one please tell me ..how to find out the friend user between two columns in sql database? In other words i wanted to get the corresponding data from
Find Cylinder area By inputting value from user
Find Cylinder area By inputting value from user  Hello Sir I need the code for calculating the area of a cylinder in which it asks radius value from user and then calculate area using this radius value. Please provide me
A program to find the sum of odd number
the console. Now here is the simple example which will help you to find the sum of odd...A program to find the sum of odd number In this section you will learn how to find the sum of odd number in the series up to the given number in java
Find Sum of Diagonals of Matrix
elements. Here we are going to find the sum of Primary diagonal (From left top...Find Sum of Diagonals of Matrix You all know that a matrix is a rectangular...) of the matrix from the given two dimensional array. See the following matrix
find the given input is integer or string
find the given input is integer or string  simple coding for to check the given input value is integer or no.If the given value is integer display "Value is integer" otherwise "Value is not a integer"?   class
Java Matrix Addition Example
Java Matrix Addition Example In this tutorial, you will learn how to find the sum of two matrices. You may have solved many Matrix Operations in Mathematics... the sum of two matrices of any order using the java language. In the given program
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26
Sum of two Matrix
Sum of  two Matrix       In this section, we are going to calculate the sum of two matrix... to this. In this program we are going to calculate the sum of two matrix. To make this program
Find sum of series
Find sum of series This section illustrates you how to find the sum of n terms... function that takes the parameter 'n' up to which the sum of the series... sum(int n) { if (n == 1) return 1.0; return sum(n - 1) + 1.0 / n
ask a user to enter 5 integer
ask a user to enter 5 integer  make a program that enter 5 numbers then identify the largest and the smallest number sample program 2 4 3 5 6 the smallest number: 2 the largest number: is 6 66
Find sum of all the elements of matrix using Java
Find sum of all the elements of matrix using Java A matrix is a rectangular... the following code, we have allowed the user to enter the number of rows and columns and the elements they wish to be in the matrix. These elements are stored into the two
retreive integer data from database
retreive integer data from database  i made a table named result having two fields 1>rollno 2>marks i creates a gui where i use a textfield and two buttons "ok" and "cancel" i want to take input from textfield
sum
sum  a program to find the sum of the alternative diagit of it ex- no=123456 sum=1+3+5=9
need help with two dimensional array that takes input from user and bubble sorts and selections sorts
need help with two dimensional array that takes input from user and bubble... cannot figure out how i can declare a two dimensional array without knowing how... how many elements are going to be input by the user?   Here is a code
Two user chess game - Applet
Two user chess game  Write a program for a two user chess game(Users must be on different systems)? please send me this source code to my mail id with step by step explanation
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
Find sum of the squares of Array elements
Find sum of the squares of Array elements In this section, you will learn how to compute the sum of the squares of the array elements. For this, we have allowed the user to enter 5 numbers, to be stored into the array. Then we have
Change the user input to integer
Change the user input to integer   ... will create a object of a Rectangle class. Now we ask the user to input two values... an integer value after the compilation of a program and force the JVM to ask
to read number from user
to read number from user  1)print the positive equivalent of the number 2) check if the no is integer or not 3) find the square root of the number 4) find the cube of the number
Sum of integers
Sum of integers  A Java program that reads an integer value from the user and displays i) the sum of all even integers between 1 and the input... value both inclusive Example: User enters 7. Sum of even integers = 2+4+6 = 12 Sum
Calculating Sum of two Multidim
Sum of Multidimensional Arrays   ... that will calculate the sum of the matrix. To make this program run we need to declare two multidimensional array of type int. Firstly calculate the length
pie chart flex and sum from hql request
pie chart flex and sum from hql request  hi, i work with flex... d.intituleDeleg,SUM(s.usagePedag ),ROUND((((SUM(s.usagePedag ))/(SUM(s.ordidispo)))*100),0), SUM(s.ordidispo) from Statistiqueordinateur s,Delegation d,Etablissement e
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
How to store two integer value in a separate file and retrieve those values
How to store two integer value in a separate file and retrieve those values  I need to save two values so i can use those values later i came up with idea of saving those values in a separate file and updating values in file
search in Two Tables to Find data and view by jsp
search in Two Tables to Find data and view by jsp  hi i want search in Two Tables to Find data and view by jsp <%@page import... (create two table the first table: the bills for user the admin insert
To find first two maximum numbers in an array
To find first two maximum numbers in an array  Java program to find first two maximum numbers in an array,using single loop without sorting array
Find User Home Directory
Find User Home Directory        In this example we are find user home directory. We... information. The method used into this example
Java Sum of Digits
Java Sum of Digits In this Java Tutorial section, you will learn how to find the sum of multidigit number. For this purpose, we have allowed the user to enter multidigit number. User can enter any digit number but cannot exceed to 9 digit
sum
; sum=sum+s; if(i==n){ System.out.print(s...+"+"); } System.out.print("\nSum of the series : "+sum
 

 

 

DMCA.com