write a program to accept two number form user and find the sum difference , product of these two number.
Answers
Answer:
import java.util.Scanner;
public class Exercise9 {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Input 1st integer: ");
int firstInt = in.nextInt();
System.out.print("Input 2nd integer: ");
int secondInt = in.nextInt();
System.out.printf("Sum of two integers: %d%n", firstInt + secondInt);
System.out.printf("Difference of two integers: %d%n", firstInt - secondInt);
System.out.printf("Product of two integers: %d%n", firstInt * secondInt);
System.out.printf("Average of two integers: %.2f%n", (double) (firstInt + secondInt) / 2);
System.out.printf("Distance of two integers: %d%n", Math.abs(firstInt - secondInt));
System.out.printf("Max integer: %d%n", Math.max(firstInt, secondInt));
System.out.printf("Min integer: %d%n", Math.min(firstInt, secondInt));
}
}
Explanation:
Hope it helps ☺️☺️
Plz mark me as brainliest ✌️✌️ and follow me
import java.util.*;
import java.util.*;public class Number
import java.util.*;public class Number{
import java.util.*;public class Number{⠀⠀public static void main (String args [])
import java.util.*;public class Number{⠀⠀public static void main (String args [])⠀⠀{
import java.util.*;public class Number{⠀⠀public static void main (String args [])⠀⠀{⠀⠀Scanner in = new Scanner (System.in);
import java.util.*;public class Number{⠀⠀public static void main (String args [])⠀⠀{⠀⠀Scanner in = new Scanner (System.in);⠀⠀int a,b,s,d,p;
⠀⠀System.out.println("Enter the two numbers :");
⠀⠀System.out.println("Enter the two numbers :");⠀⠀a = in.nextInt();
⠀⠀System.out.println("Enter the two numbers :");⠀⠀a = in.nextInt();⠀⠀b = in.nextInt();
⠀⠀System.out.println("Enter the two numbers :");⠀⠀a = in.nextInt();⠀⠀b = in.nextInt();⠀⠀s = (a+b);
⠀⠀System.out.println("Enter the two numbers :");⠀⠀a = in.nextInt();⠀⠀b = in.nextInt();⠀⠀s = (a+b);⠀⠀d = (a-b);
⠀⠀System.out.println("Enter the two numbers :");⠀⠀a = in.nextInt();⠀⠀b = in.nextInt();⠀⠀s = (a+b);⠀⠀d = (a-b);⠀⠀p = (a*b);
⠀⠀System.out.println("Sum of the two numbers =" +s);
⠀⠀System.out.println("Sum of the two numbers =" +s);⠀⠀System.out.println("Difference of the two numbers =" +d);
⠀⠀System.out.println("Sum of the two numbers =" +s);⠀⠀System.out.println("Difference of the two numbers =" +d);⠀⠀System.out.println("Product of the two numbers =" +p);
⠀⠀}
⠀⠀}}