00:01
Hello students we need to write a java program to calculate the sum and average value of array elements we need to find right so let's start with our java program we need to write here so we can write java program to calculate to calculate the sum and average of values of array elements right so calculate the sum and average value of array elements.
00:40
Now let's start with our program.
00:43
So we can now start with import import java.
00:49
Dot utel library here.
00:52
Dot scanner.
00:55
Right.
00:56
So program is started.
00:57
Now we need to define our class which is public public class.
01:03
Public class.
01:04
We can define this class by abj underscore sum.
01:10
Right.
01:10
So now we need to start our function, which is public static, public static, void, main and function started with string, string, args, bracket close.
01:31
Now what we write in the next term is, so this is basically args.
01:38
So now we need to declare all the variables right here so we can write int, int and add is equal to 0 and we can write here float value which will calculate our average.
01:55
Now what we need to do is we need to define a variable using scanner.
02:01
Scanner a is equal to we need to write new scanner scanner a is equals to new scanner system dot in system dot in we need to write here system dot ln right system dot in so now what we write here in the next step so we need to we need to print a message right here system dot out print system dot out print print ln right here and we need to print a message enter the number of elements number of enter the number of elements in array right and we need to scan that value right here so how can we scan that value so so and is equal to which we already defined n is equal to a dot a dot if we are writing here a dot and next int a dot next int right now now we can write here int and we are declaring our array b n with new int and maximum size of the array would be so we are what we are doing is we are assigning total elements that would be taken in the arrays and right.
03:41
So basically what we are doing, we are printing a message again to read the values in the array.
03:47
System dot out, dot print.
03:53
So basically system dot out.
03:55
Print ellen will be here and here also.
03:58
So we need to print a message and enter the elements you want to enter right.
04:04
So enter the elements, we need to print a message right here.
04:09
So user will enter the message right.
04:12
And what will happen then we need to scan all the values entered by user, right? so into we need to take here, we need to take here a value in the i which is zero.
04:25
We have defined its data type and this will value will go up to an increment will be happen...