Menu



Java program for addition of two number


addition.java

import java.util.Scanner;
class Addition
{
public static void main(String args[])
{
int p, q, r;
System.out.println("Enter two integers to calculate their sum: ");
Scanner sc = new Scanner(System.in); //System.in An InputStream which is typically connected to keyboard input of console programs.
p = sc.nextInt(); //scan data for input of integer value
q = sc.nextInt();
r = p + q;
System.out.println("Sum of entered integers = "+r);
}
}

Run it yourself

Output

addition









Connection failed: SQLSTATE[28000] [1045] Access denied for user 'studentdb'@'localhost' (using password: YES)

Subscribe