Answer to Question #283228 in Java | JSP | JSF for Anderson

Question #283228

Write a program in java to store marks of 10 students out of 100 in a single dimension array then it was decided to give 5 marks grace to each student with a condition that maximum mark cannot exceed 100. Then display the new marks from the array in one line.


1
Expert's answer
2021-12-28T10:03:46-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 marks[] = new int[10];


		for (int i = 0; i < 10; i++) {
			System.out.print("Enter the mark for the student " + (i + 1) + ": ");
			marks[i] = keyBoard.nextInt();
		}
		for (int i = 0; i < 10; i++) {
			if (marks[i] < 100) {
				marks[i] += 5;
			}
		}


		for (int i = 0; i < 10; i++) {
			System.out.println("The mark for the student " + (i + 1) + ": " + marks[i]);
		}


		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