You need to create a program that takes in two integers as input. You ought to define two separate methods – one method to find the product of the two integers and another to find the average and round it down to the nearest whole number. The first input will represent the first integer, while the second input will be the second integer. You must print the product and average as output.
Calling methods
Product and rounded average of two integers
Report a typo
Sample Input 1:
4
5Sample Output 1:
20
4Sample Input 2:
12
3Sample Output 2:
36
7Write a program in Java 17
import java.util.Scanner;
public class Main {
// Method 1: This method will compute the product of two numbers.
static int product(int num1, int num2) {
// Write your code here.
}
// Method 2: This method will compute the average of two numbers
// and round it down to the nearest whole number.
static int average(int num1, int num2) {
// Write your code here.
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num1 = scanner.nextInt();
int num2 = scanner.nextInt();
// Call the methods here and print the result.
}
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.