SHARE
TWEET

Untitled

a guest Jun 2nd, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.File
  2.  
  3. fun main(args: Array<String>) {
  4.     val lowestStudentNum: MutableMap<String, Int> = mutableMapOf()
  5.     val lowestStudentNumGrade: MutableMap<String, Int> = mutableMapOf()
  6.     File("grades.txt").forEachLine { line ->
  7.         var parts = line.split('|')
  8.         var num = parts[0].toInt()
  9.         var grade = parts[2].toInt()
  10.         var className = parts[1]
  11.        
  12.         if (!lowestStudentNum.contains(className) || num < lowestStudentNum[className]!!) {
  13.             lowestStudentNum.put(className, num)
  14.             lowestStudentNumGrade.put(className, grade)        
  15.         }
  16.     }
  17.     println(lowestStudentNumGrade)
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top