Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING Standard ML please do all the functions in one .sml file all that was given in the exercise is here ANSWER first couple subparts

USING Standard ML image text in transcribed
image text in transcribed
please do all the functions in one .sml file
all that was given in the exercise is here
ANSWER first couple subparts
In this assignment, you will write simple SML functions that manipulate student grades in a class. Assume that a student's record is represented as a quadruple of type int*string*real*real which contains the students ID, name, midterm exam grade, and final exam grade, respectively. (1) Implement a function score that takes a student record and computes the student's composite score, assigning 40% to the midterm and 60% to the final. (2) Implement a function scores that takes a list of student records and returns a list of pairs of type int*real consisting of each student's ID and composite score, respectively. (3) Implement a function getByID that takes a list of student records and an integer i and returns the record of the student whose ID is i. Assume the list contains the desired student (do not worry about the case where the desired student is not in the list). (4) Implement a function whoFailedMidterm that takes a list of student records and returns a list of the names of the students who received less than 60 on the midterm exam. (5) Implement a function allPassedFinal that takes a list of student records and returns true if all the students received a grade greater than or equal to 60 on the final exam, and false otherwise (6) Implement a function count PassedCourse that takes a list of student records and returns the number of students who received a composite score greater than or equal to 60. (7) Implement a function studentsInRange that takes a list of student records and a pair of reals range and returns a list of the records of the students who received a composite score in between #1 range and #2 range (exclusive) (8) Implement a function count Students InRanges that takes a list of student records and a list of pairs ranges and returns the number of students who received a composite score in at least one of the ranges in ranges. The ranges may overlap so be careful not to double- count students that fall in multiple ranges. (9) Implement a function student WithHighest Score that takes a list of student records and returns the record of the student with the highest composite score. Assume the class always has at least one student (do not check for the case when the list is empty). (10)Implement a function insertAssignmentGrade that takes a list of student records and a list of assignment grades and returns a list of amended student records that include the assignment grade as a third field in the tuple (the returned list will have type int*string real real*real). Assume that the two lists are of equal size (do not check for the case where their size mismatches). Evaluating a correct homework solution should generate the bindings below. However, keep in mind that generating these bindings does not guarantee that your solutions are correct. Make sure to test your functions before submitting. val score - fn: int string real real -> real val scores = fn: (int * string * real real) list -> (int * real) list val getByID - In : (int * string real * real) list *int -> int string * real * real val whoFailedMidterm = fn : (int * string * real real) list -> string list val allpassedFinal - En : (int. string * real . real) list -> bool val count PassedCourse - En: (int * string * real * real) list -> int val studentsInRange = fn : (int * string real * real) list* (real * real) -> (int string * real * real) list val count StudentsInRanges : (int * string . real * real) list (real * real) list -> int val studentWithHighest Score = fn (int * string real * real) list -> int * string + real * real val insertAssignment Grade = fn (int * string real * real) list * real list -> (int * string real * real . real) list in

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

Students also viewed these Databases questions