# Kotlin program to calculate and display student grades

Kotlin | Student Grade Program: Here, we are implementing a Kotlin program to calculate and display student grades.
Submitted by IncludeHelp, on May 12, 2020

Given student's marks in multiple subjects, we have to find and print student grade.

Consider the following conditions,

```    Percentage >=80 -> A
Percentage >=60 -> B
Percentage r>=40 -> C
else D

Note: Maximum Marks 100 in Each Subject
```

Example:

```    Input:
Hindi = 67
English = 98
Physics = 34
Chemistry = 67
Maths = 90

Output:
Total Marks = 356.0
Percentage = 71.2
```

### Program to calculate and display student grades in Kotlin

```package com.includehelp

import java.util.*

//Main Function , Entry point of Program
fun main(args: Array<String>) {

//array of subjects Names
val subjectName = arrayOf<String>("Hindi","English","Physics","Chemistry","Maths")

//Input Stream
val scanner = Scanner(System.`in`)

//Declare Array to Contain Subjects marks
val marksArray = DoubleArray(5)

//Start Input Subjects Marks
println("Input Marks->")
for(i in marksArray.indices){
print("\${subjectName[i]} : ")
marksArray[i] = scanner.nextDouble()
}

//Calculate Total Marks in All Subjects
val total = marksArray.sum()

//Calculate Percentage
val percentage = marksArray.average()

//Print Total and Percentage
println("Total of All subjects Marks : \$total")
println("Percentage : \$percentage")

//To find out Grade based on Percentage
when{
}
}
```

Output

```Run 1:
Hindi : 67
English : 98
Physics : 34
Chemistry : 67
Maths : 90
Total of All subjects Marks : 356.0
Percentage : 71.2
---
Run 2:
Hindi : 56
English : 32
Physics : 98
Chemistry : 67
Maths : 12
Total of All subjects Marks : 265.0
Percentage : 53.0
```