[st10@nrs-labs lab8]$ funct_play
----------------------------------------------
Welcome to the 2016-10-13 version of funct_play!
----------------------------------------------
Are there any already-created C++ functions (in the current
working directory) which you would like to be able to use
within your new function?
(type y if so, n if not)
your answer: n
Is your new function already in a file in the local directory?
(answer y or n): n
--- Entering a new function ---
Enter the name for your new function:
Function name: grade_in_range
***** DESIGN RECIPE STEP 2.1: *****
Enter the signature comment for the function grade_in_range, using format:
grade_in_range : parameter_type parameter_type ... -> return_type
signature: grade_in_range : double -> bool
Your signature for grade_in_range is:
--------------------------------------------------------
signature: grade_in_range : double -> bool
--------------------------------------------------------
***** DESIGN RECIPE STEP 2.2: *****
Enter a purpose statement for the function grade_in_range,
"a brief comment of what the function is to compute" [HtDP,
p. 18]
(enter a line containing NOTHING but q and typing the Enter key
to show when your purpose statement is complete):
purpose: expects a numeric grade, and returns whether it
is in the desired range [0, 100]
q
Purpose statement:
---------------------------------------------------------------
purpose: expects a numeric grade, and returns whether it
is in the desired range [0, 100]
---------------------------------------------------------------
***** DESIGN RECIPE STEP 2.3: *****
Enter the header for the function, using the format:
return_type grade_in_range (param_type param_name, ...)
Function header:
bool grade_in_range(double grade)
Your header for grade_in_range is:
-------------------------------------------------
bool grade_in_range(double grade)
-------------------------------------------------
***** DESIGN RECIPE STEP 3: *****
Enter at least one example call of function grade_in_range
including input(s) and the expected output given those
input(s); for example,
my_funct(3, 4) == 12
my_funct(0, 0) == -3
(enter a line containing NOTHING but q and typing the Enter key
to show when you have entered all of your examples):
Examples: grade_in_range(-3) == false
grade_in_range(0) == true
grade_in_range(1.5) == true
grade_in_range(100) == true
grade_in_range(105) == false
q
Examples:
---------------------------------------------------------------
examples: grade_in_range(-3) == false
grade_in_range(0) == true
grade_in_range(1.5) == true
grade_in_range(100) == true
grade_in_range(105) == false
---------------------------------------------------------------
BEFORE you type in grade_in_range's body --- are there any
NEW named constants that you want to CREATE?
(answer y or n):
your reply: y
type in your new named constant declaration, using the format:
const const_type CONST_NAME = expression;
new declaration:
const double MIN_GRADE = 0.0;
do you have another named constant declaration?
(enter y or n):
your reply: y
type in your new named constant declaration, using the format:
const const_type CONST_NAME = expression;
new declaration:
const double MAX_GRADE = 100.0;
do you have another named constant declaration?
(enter y or n):
your reply: n
NOTE --- if a named constant was already declared for an
OLD function that grade_in_range calls, then it SHOULD be
visible for use in grade_in_range, too...
(at least, it should be the way that funct_play sets these up ---
we will discuss SCOPE later, and then perhaps discuss some
other const declaration placement options.
***** DESIGN RECIPE STEPS 4, 5 *****
Enter the template/body of the grade_in_range (the part following the header),
being sure to include the { and } that should enclose it.
(enter a line containing NOTHING but q and typing the Enter key
to show when grade_in_range's body is complete):
Enter body following the header:
bool grade_in_range(double grade)
{
return (grade >= MIN_GRADE) and (grade <= MAX_GRADE);
}
q
grade_in_range's body:
----------------------------------------------------------------
{
return (grade >= MIN_GRADE) and (grade <= MAX_GRADE);
}
----------------------------------------------------------------
COMPILING grade_in_range.cpp...
-----------------------------------------------------------------
grade_in_range.cpp COMPILED! 8-)
Would you like to run grade_in_range_ck_expect?
(type y if so, n if not)
your answer: y
testing grade_in_range: true's should mean passed:
---------------------------------------
(grade_in_range(-3) == false): true
(grade_in_range(0) == true): true
(grade_in_range(1.5) == true): true
(grade_in_range(100) == true): true
(grade_in_range(105) == false): true
Enter a C++ expression involving:
grade_in_range
...and type enter
(or type q to quit):
q
Quitting funct_play ... goodbye.
[st10@nrs-labs lab8]$