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.
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();
}
}
Comments
Leave a comment