Welcome to ICSE Java Answers. Ask any questions you have related to Java and we will answer them.
Java is a registered trademark of Oracle. This site is in no way related to or endorsed by Oracle.

WAP that will show the teacher to enter the marks scored in computer by 10 students and the find and print the average marks of the group

0 votes
asked by Papri Paul (10 points)

2 Answers

0 votes

sumOfMarks is used to store the sum of the marks entered.

In a for loop which runs for 10 times, the marks are taken as input and added to sumOfMarks.

Average is calculated by dividing sumOfMarks by 10.0 (not 10. If you divide by 10, you won’t get the digits after decimal point)

import java.util.Scanner;

public class Multiples {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int sumOfMarks = 0;
        System.out.println("Enter marks of 10 students: ");
        for (int i = 0; i < 10; i++) {
            int marks = scanner.nextInt();
            sumOfMarks = sumOfMarks + marks;
        }
        double average = sumOfMarks / 10.0;
        System.out.println("Average = " + average);
    }
}

Sample Output

Enter marks of 10 students: 
90
85
99
98
97
82
80
90
99
95
Average = 91.5

 

answered by Ranjith (2,048 points)
0 votes
You could also use InputStream or the java.io.* package. If you want the full program, please inform.
answered by Soham Thakurata (333 points)
...