Print sum and average of 5 numbers in Java
Java Output - Question 10
In this question, we will see how to print the sum and average of 5 numbers in java programming using the java output. To know more about java output click on the java output lesson.
Q10) Write a program in java to print the sum and average of 5 number like 9, 5, 8, 34, and 15.
Program
public class Q10
{
public static void main(String args[])
{
System.out.println("Sum of of 9, 5, 8, 34, and 15 = " + (9+5+8+34+15));
System.out.println("Average of 9, 5, 8, 34, and 15 = " + (9+5+8+34+15)/5.0);
}
}
Output
Sum of of 9, 5, 8, 34, and 15 = 71 Average of 9, 5, 8, 34, and 15 = 14.2