0% found this document useful (0 votes)
4 views1 page

Java Program to Calculate Average

The document contains a Java program that calculates the average of three integers entered by the user. It uses the Scanner class to read input and defines a method to compute the average. The result is then printed to the console.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Java Program to Calculate Average

The document contains a Java program that calculates the average of three integers entered by the user. It uses the Scanner class to read input and defines a method to compute the average. The result is then printed to the console.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

import [Link].

Scanner;

public class AverageCalculator {

public static void main(String[] args) {


Scanner input = new Scanner([Link]);

[Link]("Enter three integers:");


int num1 = [Link]();
int num2 = [Link]();
int num3 = [Link]();

double average = calculateAverage(num1, num2, num3);

[Link]("The average is: " + average);


[Link]();
}

public static double calculateAverage(int a, int b, int c) {


return (double) (a + b + c) / 3;
}
}

You might also like