0% found this document useful (0 votes)
39 views1 page

CS105 Lab 3: Check-Expect Check-Within

This lab focuses on practicing the design recipe for writing functions in Racket, including using check-expect and check-within for testing. Students are instructed to follow the Assignment Style Guide. The lab contains 5 problems - writing functions to determine the type of roots of a quadratic equation, return a grade based on a mark, compare two numbers and return a message, return a digit string based on a single-digit number, and return the day of the week for a number 0-6 or return an error message.

Uploaded by

AndrewChan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views1 page

CS105 Lab 3: Check-Expect Check-Within

This lab focuses on practicing the design recipe for writing functions in Racket, including using check-expect and check-within for testing. Students are instructed to follow the Assignment Style Guide. The lab contains 5 problems - writing functions to determine the type of roots of a quadratic equation, return a grade based on a mark, compare two numbers and return a message, return a digit string based on a single-digit number, and return the day of the week for a number 0-6 or return an error message.

Uploaded by

AndrewChan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

CS105 Lab 3

The purpose of this lab is for you to get practice in using the design recipe, including testing.
Make sure to use check-expect or check-within, as appropriate. Follow the instructions given
in the Assignment Style Guide.

1. In solving a quadratic equation, ax2 + bx + c = 0, there are three types of roots depending
on the determinant, b2 4ac. If the determinant is negative (less than 0), then it is
imaginary roots, if it is equal to 0, then it is equal roots, otherwise it is two distinct
roots.
Write a function called rootsType that consume the three numbers, a, b, and c of a quadratic
equation above, and display the type of roots as defined above.

2. Write a function called grade that display a string grade, corresponding to the value of mark
given in the following table:
Mark Grade
0 x < 50 FL
50 x < 65 PS
65 x < 75 CR
75 x < 85 DI
85 x 100 HD

3. Write a function named compareResult that consumes two numbers, num1 and num2, and
display appropriate message as described below. If num1 is greater than num2, display the
message "First is larger"; otherwise if num1 is less than num2, display the message "Second is
larger", otherwise display the message "Both equal".

4. Write a function named digitString that consumes a single-digit integer number, and return
the corresponding digit as string, that is, if parameter is 1, then returned string is one, if
parameter is 2, then returned string is two, etc. If it is not a single-digit integer number,
return the string other.

5. Write a function that will consume an integer. If the integer is between 0 and 6 inclusive, the
day of the week that corresponds to the integer will be printed. For example, if user entered
1, then the program should display "Monday", 3 "Wednesday", etc. The exception is 0,
which represents "Sunday". Any values other than 0 to 6 should result in an error message
(Invalid day number) to be printed.

You might also like