what is code for adding two integers in java?, Computer Engineering

import java.util.Scanner;
 
class AddNumbers
{
   public static void main(String args[])
   {
      int x, y, z;
      System.out.println("Enter two integers to calculate their sum ");
      Scanner in = new Scanner(System.in);
      x = in.nextInt();
      y = in.nextInt();
      z = x + y;
      System.out.println("Sum of entered integers = "+z);
   }
}

Posted Date: 3/11/2013 2:07:42 AM | Location : United States





you need to use the + operator for adding nos in java

ex,

int a=9;

int b=1;

int s=a+b;

System.out.println(s);

the output will be 10

Posted by | Posted Date: 3/11/2013 2:08:04 AM


Related Discussions:- what is code for adding two integers in java?, Assignment Help, Ask Question on what is code for adding two integers in java?, Get Answer, Expert's Help, what is code for adding two integers in java? Discussions

Write discussion on what is code for adding two integers in java?
Your posts are moderated
Related Questions
Enumerate about the Decimal Arithmetic Unit The user of the computer input data in decimal numbers and receives output in the decimal form. But a CPU with ALU can perform arith

how to write mobile keypad program in c++

How do I connect to an SQL Server instance that is running on a machine with multiple instances of SQL Server 2000? Ans) Every instance of MS SQL Server must be listening on a d

Downcasting concept is the casting from a general to a more particular type, i.e. casting down the hierarchy in programming

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4  A loop invariant is

Determine the salient features of a parallel programmable interface, 8255. 24 I/O lines in 3 8-bit port groups - A, B, C A, B can be 8-bit input or output ports C

In sense of Database Management System (DBMS) LOGICAL DATABASE is a database Structure. False LOGICAL DATABASE is not a database Structure.

Question: (a) Prepare short notes on the model primitives in Director MX 2004. (b) Therefore using the box primitive write codes to prepare a new model resource of length 50

Explain analysis and synthesis phase of a compiler. The synthesis and analysis phases of a compiler are: Analysis Phase: In this breaks the source program in constituent

Which is valid syntax of the Fork and Join Primitive? Ans. A valid syntax of the Fork and Join Primitive is as given below: Fork Join