Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write a user define function quiz_fct to display student quiz score’s com

ID: 3741149 • Letter: P

Question

Please write a user define function quiz_fct to display student quiz score’s comments based on student’s score. The function quiz_fct will display comments based on a student’s quiz scores.

(1) First, you are required to load data from quiz.csv in R to create a data frame and name it quiz_df.

Got this: quiz_df<-read.table("source of file", header = TRUE, sep=",")

When creating function quiz_fct, you need to use a loop and multi-if-elseif-else control constructs inside the function even_fct to complete your task.

Comments’ rules if student’s quiz score match following status:

Quiz < 60 # display comment “Failed”

Quiz >= 60 and Quiz < 70 # display comment “Poor”

Quiz >= 70 and Quiz < 80 # display comment “Average”

Quiz >= 80 and Quiz < 90 # display comment “Good”

Quiz >= 90 # display comment “Great”

> quiz_fct <- function(x){

comment<-c() # create an empty vector and name it comment

length <- nrow(x) # number of rows inside the data frame quiz_df

……… # your codes

……… # your codes

x<- data.frame(x,comment)

return(x) }

> y <- quiz_fct(quiz_df)

> y

name quiz1 comment

1 Jack 80 Good

2 John 70 Average

3 Jennifer 90 Great

4 Joe 60 Poor

5 Judy 50 Failed

6 Jay 90 Great

7 July 100 Great

8 Jason 100 Great

9 Jill 100 Great

Explanation / Answer

the below function helps u to evaluate the results of quiz with the parameter as score

void quiz_fct(int s)

{

if(s<60)

{

printf("Failed");

}

else if (s>=60 && s<70)

{

printf("Poor");

}

else if( s>=70 && s<80)

printf("Average");

else if(s>=80 && s<90)

printf("Good");

else

printf("Great");

}