Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java test program, all the code should be in a single main method, that

ID: 3916845 • Letter: W

Question

Write a Java test program, all the code should be in a single main method, that prompts the user for two integers and then prints the

sum
difference
product
quotient of the first integer divided by the second integer
remainder of the first integer divided by the second integer
maximum
minimum

Format your output using printf. Please label each of your answers.

Please submit your .java file for grading.

Starter Code

import java.util.Scanner;

public class MathFun
{
public static void main(String[] args)
{
// your code here

}
}

Explanation / Answer

MathFun.java

import java.util.Scanner;

public class MathFun

{

public static void main(String[] args)

{

// your code here

Scanner scan = new Scanner(System.in);

System.out.println("Enter the first number: ");

int first = scan.nextInt();

System.out.println("Enter the second number: ");

int second = scan.nextInt();

System.out.printf("Sum = %d ", first + second);

System.out.printf("Difference = %d ", first - second);

System.out.printf("Product = %d ", first * second);

System.out.printf("Quotient = %d ", first / second);

System.out.printf("Remainder = %d ", first % second);

int max, min;

if(first > second){

max = first;

min = second;

} else {

max = second;

min = first;

}

System.out.printf("Maximum = %d ", max);

System.out.printf("Minimum = %d ", min);

}

}

Output:

Enter the first number:
10
Enter the second number:
3
Sum = 13
Difference = 7
Product = 30
Quotient = 3
Remainder = 1
Maximum = 10
Minimum = 3

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote