Array In Java

Guna Sekaran - Feb 17 - - Dev Community
package array;

public class Array_day1 {
    public static void main(String[] args) {

        int[] marks = { 75, 78, 76, 67, 95};
        System.out.println(marks.length + "--length count");// it's a pre-defined method for marks count 
        int total = 0;
        int count=0;

        for (int i = 0; i < marks.length; i++) {
            // we use the marks.length for storing multiple values

            total = total + marks[i];
            count++;

        }
        System.out.println(count+"--normal count");
        System.out.println(total + "--total marks");
        System.out.println(total/5+"%-- percentage");

    }

}

.........................................................................

OUTPUT:
5--length count
5--normal count
391--total marks
78%-- percentage


Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . .