write a java program to find the addition and subtraction of two numbers
Answers
Explanation:
input
import java.util.Scanner;
public class JavaProgram
{
public static void main(String args[])
{
int first, second, add, subtract, multiply;
float devide;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter Two Numbers : ");
first = scanner.nextInt();
second = scanner.nextInt();
add = first + second;
subtract = first - second;
multiply = first * second;
devide = (float) first / second;
System.out.println("Sum = " + add);
System.out.println("Difference = " + subtract);
System.out.println("Multiplication = " + multiply);
System.out.println("Division = " + devide);
}
}
output.
Enter Two Numbers : 12
5
Sum = 17
Difference = 7
Multiplication = 60
Division = 2.4
import java.util.*;
public class Sum_Subtraction
{
public static void main(String args[])
{
Scanner in= new Scanner(System.in);
int a,b,c,d;
System.out.println("Enter the two numbers");
a=in.nextInt();
b=in.nextInt();
c=a+b;
d=a-b;
System.out.println("Display the sum"+c);
System.out.println("Display the subtraction"+d);
}
}