**Java program for addition, subtraction, multiplication and division** has been shown here. These are the basic arithmetic operations.

#### Page content(s):

#### Additional content(s):

## 1. Java program & output for Addition, Subtraction, Multiplication & Division

Code has been copied

/********************************************************************** alphabetacoder.com Java program for addition, subtraction, multiplication and division *********************************************************************/ import java.util.Scanner; public class Main { public static void main(String []args){ // declare instances Scanner sc = new Scanner(System.in); // declare variables double a, b, w, x, y, z; // take input from user System.out.print("Enter first number: "); a = sc.nextDouble(); System.out.print("Enter second number: "); b = sc.nextDouble(); // compute operation w = a + b; x = a - b; y = a * b; z = a / b; // display output System.out.println("Addition: "+w); System.out.println("Subtraction: "+x); System.out.println("Multiplication: "+y); System.out.println("Division: "+z); } }

Output

Enter first number: 17

Enter second number: 2

Addition: 19.0

Subtraction: 15.0

Multiplication: 34.0

Division: 8.5

## No comments:

## Post a Comment

If you have any doubts or suggestions, please leave a note.