# Sum and Average of Five Numbers in Java

Machine Problem

Write a program that will ask the user to give five numbers and then our program will find the total sum and average of five numbers using an array.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My mobile number here in the Philippines is 09173084360.

=================================================

Want to support my channel?

GCash Account

09173084360

Paypal

Patreon

Thank you very much for your support

/*
average_array.java
Programmer By: Mr. Jake R. Pomperada, MAED-IT
Date : July 23, 2015
Tools: NetBeans 8.0.2, Java SE 8.0

Problem No. 1:

Write a program that will ask the user to give five numbers
and then our program will find the total sum and average of
five numbers using an array.
*/

import java.util.Scanner;

class average_array {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);
char ch;

do {
int [] values;
values  = new int[5];
int x=0, total_sum=0, average=0;
System.out.println("\n");
System.out.print("Sum and Average of Five Numbers in Java");
System.out.println("\n");
for (int a=0; a<5; a++)
{
x=1;
x+=a;
System.out.print("Enter value in item no." + x + " : ");

values[a] = input.nextInt();
total_sum += values[a];
average = total_sum/5;
}
System.out.println();
System.out.print("The total sum is " + total_sum + ".");
System.out.println();
System.out.print("The average of five numbers is " + average + ".");
System.out.println();
System.out.print("\nDo you want to continue (Type y or n) : ");
ch = input.next().charAt(0);
} while (ch == 'Y'|| ch == 'y');
System.out.println();
System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
System.out.println("\n\n");
input.close();
}
}