Confidential Teaching Materials
Homework 2 Criteria
Note: To receive any credit whatsoever, your answers must be legible and readily readable in the
judgment of the grader. Add brief explanatory comments as necessary to make sure your
answers are clear and unambiguous to the grader.
[p1] 25 points
Write the headers for the following modules. You DO NOT have to write the code for the modules.
a) A module that reads in a name and GPA and returns these pieces of information to the main
algorithm.
b) A module that detemines the two roots of a quadratic equation, given the equation coefficients A,
B, and C. (You can assume that the coefficients A, B, and C will only produce real roots.)
c) Given a person’s birthday (month, day, and year), returns a string representing the day of the week
on which the person was born.
d) A module that, passed in a number, prompts the user for a second number and adds the two
numbers together, returning the result to the main algorithm.
e) A module that will return the distance between two coordinates on a two-dimensional Cartesian
plane. (Each coordinate has an x and a y component).
[c1] 25 points
Sample Answers:
GRADING CRITERIA:
a) -1 for not making it a procedure (pro)
-2 for not having the name parameter (npo)
b) -1 for not making it a procedure (pro)
-2 for not having the A, B, and C parameters (npo)
Homework 2 Criteria, Page 2 of 9
c) -2 for not making it a function (fun)
d) -1 for not making it a procedure (pro)
-1 for not making it a num (num)
e) -2 for not making it a function (fun)
Additional Deductions:
[p2] 10 points
Explain the difference between a procedure and a function. Give an example of when each would be used.
[c2] 10 points
Sample Answer:
Confidential Teaching Materials
GRADING CRITERIA:
[p3] 10 points
Give and explain 3 reasons why using good modularity a good thing.
[c3] 10 points
Confidential Teaching Materials
Homework 2 Criteria, Page 4 of 9
[p4] 5 points
Declare the appropriate constants for solving this problem.
[c4] 5 points
[p5] 12 points
Write a module that will read a grade for a single class from the user. The module should take in as a
parameter a description of the class whose grade is being entered, display “Enter the grade for <class
description>”, read in the grade from the user, and pass the grade back to the calling module.
[c5] 12 points
Sample Solution:
Confidential Teaching Materials
Homework 2 Criteria, Page 5 of 9
GRADING CRITERIA:
Header
[p6] 10 points
Write a module that will return the number of points a given letter grade is worth. The module should take
the letter grade in as a parameter and return the corresponding point value. You may assume that only
valid letter grades (i.e. A, B, C, D, and F) will be passed to the module.
[c6] 10 points
Sample Solution:
Confidential Teaching Materials
Homework 2 Criteria, Page 6 of 9
GRADING CRITERIA:
Header
Body
Additional Deductions:
[p7] 10 points
Write a module that will compute the student’s GPA using the formula described above. The module will
take in as parameters the student’s letter grades for each of the five required classes, and calculate the grade
point average (a number).
[c7] 10 points
Sample Solution:
function GPA returnsa Num ( civil_procedure_grade,
legal_writing_grade,
Confidential Teaching Materials
Homework 2 Criteria, Page 7 of 9
GRADING CRITERIA:
Header
-1 for not having it return a num (num)
Body
-6 for wrong computation (log)
-1 for not weighing the scores by the number of hours (log)
Additional Deductions:
-1 for each poor variable or procedure name (prn)
[p8] 10 points
Write a module that takes in as a parameter a student’s GPA and calculates a result of true if they have lost
their scholarship, or false otherwise.
[c8] 10 points
Sample Solution:
function Has_Lost_Scholarship returnsa Boolean (gpa isoftype in Num)
Confidential Teaching Materials
GRADING CRITERIA:
Body
-2 for not having the proper test (log)
Additional Deductions:
-1 for each poor variable or procedure name (prn)
[p9] 30 points
Write an algorithm that will allow a student to actually use all of the modules you have created. The
algorithm should perform the following steps:
1. Read in grades for all of the five classes.
2. Compute and print the student’s GPA.
3. Print whether or not the student has lost their scholarship.
[c9] 30 points
Sample Solution:
algorithm Compute_Grades
civil_procedure_grade,
Confidential Teaching Materials
Homework 2 Criteria, Page 9 of 9
GRADING CRITERIA:
-1 points for not having “algorithm xxxx” (alg)