Write a Java program to count the average of two integer numbers.

Q.4 Write a Java program to count the average of two integer numbers.

Solution :- 

import java.util.Scanner;

public class AverageCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);


System.out.print(“Enter the first integer: “);
int num1 = scanner.nextInt();
System.out.print(“Enter the second integer: “);
int num2 = scanner.nextInt();
double average = (num1 + num2) / 2.0;
System.out.println(“The average of ” + num1 + ” and ” + num2 + ” is: ” + average);

}
}

Output :- 

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.