CS105 Lab 3: Check-Expect Check-Within
CS105 Lab 3: Check-Expect Check-Within
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.