Question:
Write a Java program to calculate the remainder and quotient of two integer numbers, then calculate the product and the average of the remainder value and quotient value, and show the output.
Code:
public class Example { public static void main(String[] args) { int integer1 = 33; int integer2 = 7; int quotient = integer1 / integer2; int remainder = integer1 % integer2; int product = quotient * remainder; double average = (double)(quotient + remainder) / 2; System.out.println("Quotient: " + quotient); System.out.println("Remainder: " + remainder); System.out.println("Product: " + product); System.out.println("Average: " + average); } }
Output:
$ java Example Quotient: 4 Remainder: 5 Product: 20 Average: 4.5