re: Daily Challenge #68 - Grade Book VIEW POST

FULL DISCUSSION
 

Solved Using Purescript inspired from Amin Nairi

grade :: Int -> String
grade average =
    case compare (mod 10 average) 5 of
        EQ ->
          ""

        LT ->
          "-"

        GT ->
          "+"  

resultGrade :: Int -> Int -> Int -> String
resultGrade grade1 grade2 grade3 =
   let 
        average = (grade1 + grade2 + grade3) / 3

        finalGrade = grade $ fromMaybe 0 $ fromNumber $ Math.round 
                      (toNumber average)
   in
   if average < 60 then 
       "F" <> finalGrade

   else if average < 70 then 
       "D" <> finalGrade 

   else if average < 80 then 
       "C" <> finalGrade 

   else if average < 90 then 
       "B" <> finalGrade 

   else 
       "A" <> finalGrade
code of conduct - report abuse