Computer Science, asked by chikkutherattil8992, 11 hours ago

Write a Program and flow chart to find the average age of all students in a class.

Answers

Answered by samarthkrv
0

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

 Scanner sc = new Scanner(System.in);

 System.out.print("Enter the number of students:");

 int[] arr = new int[sc.nextInt()];

 System.out.println("Enter the marks of all " + arr.length + " students-");

 int total = 0;

     for(int i = 0; i < arr.length; i++){

         arr[i] = sc.nextInt();

         total += arr[i];

     }

 double average = total/(double)arr.length;

 System.out.println("The average of all " + arr.length + " students is " + average);

}

}

Explanation:

Similar questions