Menu
Coddy logo textTech

Recap - Grade Classifier

Part of the Logic & Flow section of Coddy's R journey. Lesson 51 of 64.

challenge icon

Challenge

Medium

Complete grade_report(names, scores). Give each student a grade with ifelse(): A from 90, B from 75, C from 50 and F below 50. Return one line per student, ada: 93 (A) Excellent, where the comment comes from a switch() on the grade: Excellent for A, Good for B, Pass for C and Retake for F.

Then add Top: followed by the students with the highest score, in input order and joined with , .

The supplied code reads the names and the scores as two comma-separated lines and prints each returned line.

Try it yourself

grade_report <- function(names, scores) {
  # Write your code here
  character(0)
}

# Supplied input/output code: keep it as it is
input <- suppressWarnings(readLines(file("stdin")))
cat(grade_report(strsplit(input[1], ",")[[1]], as.numeric(strsplit(input[2], ",")[[1]])), sep = "\n")

All lessons in Logic & Flow

Practice on your own: Online R compiler