Computer Science, asked by simplychawn, 6 months ago

java program to find the sum, difference, product and quotient of two integers

Answers

Answered by YadhuKrishnan7050
11

Hi mate

Answer is in the attachment...

Hope it helps you...

Follow me and mark me brainliest...

Attachments:
Answered by sadiaanam
0

Answer:

Here is an example of a Java program that takes two integers as input and calculates their sum, difference, product and quotient:

Explanation:

import java.util.Scanner;

public class Calculator {

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       int num1, num2;

       

       System.out.print("Enter first integer: ");

       num1 = sc.nextInt();

       System.out.print("Enter second integer: ");

       num2 = sc.nextInt();

       

       int sum = num1 + num2;

       int difference = num1 - num2;

       int product = num1 * num2;

       double quotient = (double) num1 / num2;

       

       System.out.println("Sum: " + sum);

       System.out.println("Difference: " + difference);

       System.out.println("Product: " + product);

       System.out.println("Quotient: " + quotient);

   }

}

This program uses the Scanner class to take input from the user and stores the input in the variables num1 and num2. Then it calculates the sum, difference, product, and quotient using the corresponding operators (+, -, *, /) and stores the results in separate variables. Finally, it uses the println method to print the results.

Note that in the quotient calculation, the division is casted to double to get the floating point division, otherwise the result would be integer division.

for more visit - https://brainly.in/question/51267681

#SPJ3

Similar questions