![]() |
VOOZH | about |
Given an integer array marks, which comprises of marks scored by a student (out of 100) in different subjects, the task is to assign a grade to the student. The grade is found out by taking the percentage of the marks scored by the student. The percentage is calculated as:
The grade is assigned using the following rules:
| Percentage | Grade |
|---|---|
| 90 and above | A |
| 80 to 89 | B |
| 60 to 79 | C |
| 33 - 59 | D |
| below 33 | F |
Examples:
Input: marks = { 25, 65, 46, 98, 78, 65 }
Output: C
Input: marks = { 95, 88, 98, 93, 92, 96 }
Output: A
Approach:
For more on decision making and different types of decision making constructs, refer Decision Making in Java.
Below is the implementation of the above approach:
C