Write Java program to print sum, difference, product, quotient
and remainder.
if you give me right answer I will mark you as brainliest
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));
}
}
Answer:
Please mark me brainliest
Explanation:
//program to find sum, difference, product, quotient and remainder
import java.util.*;
public class Number
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.println("Enter the first number");
int a=in.nextInt();
System.out.println("Enter the second number");
int b=in.nextInt();
double sum,diff,prod,quo,rem;
sum=a+b;
diff=a-b;
prod=a*b;
quo=a/b;
rem=a%b;
System.out.println("The sum="+sum);
System.out.println("The difference="+diff);
System.out.println("The product="+prod);
System.out.println("The quotient="+quo);
System.out.println("The remainder="+rem);
}
}