1. JAVA Program to Add and Subtract Two Numbers.
How does this program work?
- In this programme you will learn about how to add and subtract two numbers using java.
- Initially you will learn how to scan two numbers and store them in 2variables.
- And then by using the given logic you will get outputs.
Here is the code
//Addtion and Subtraction of two numbers
import java.util.Scanner;public class AddSub
{
public static void main(String args[] )
{
int a,b,add, subtract;
System.out.println("Enter Two Numbers : " span>);
Scanner skill = new Scanner(System.in);
a = skill.nextInt();
b = skill.nextInt();
add = a+b;
subtract = a -b;
System.out.println("Addition of two numbers= " + add);
System.out.println("Difference of two numbers = " +subtract);
}
}