Java Addition through user input


Addition through user input value

In this program, you’ll learn to store and add two integer numbers in Java. After addition, the final sum is displayed on the screen.

Source code

import java.io.*;
import java.util.*;
class Add
{
public static void main(String[] args)
{
Scanner ob=new Scanner(System.in);
System.out.println(“enter value of a and b”);
int x,y;
x=ob.nextInt();
y=ob.nextInt();
int z=x+y;
System.out.println(“sum of Z:”+z);
}
}

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Domain & free Hosting

Categories

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.