Answer to Question #286926 in Java | JSP | JSF for Dragon

Question #286926

Write a program to store mark of 30 students out of 100 in computer then display how many students got 100 out of 100 using linear searching.

Hint: Use single dimension array.


1
Expert's answer
2022-01-16T04:20:23-0500


import java.util.Scanner;


public class App {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		int counter=0, i, j;
		int[] studentsMarks = new int[30];
		for (i = 0; i < studentsMarks.length; i++) {
			System.out.print("Enter the student mark " + (i + 1) + ": ");
			studentsMarks[i] = keyBoard.nextInt();
		}


		for (i = 0; i < studentsMarks.length; i++) {
			if (studentsMarks[i] == 100) {
				counter++;
			}
		}
		System.out.printf("%d students got 100 out of 100\n", counter);


		keyBoard.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog