Question: The x - axis is the grind size ( 1 represents the finest grind and 8 represents the coarsest grind ) . Note that the
The xaxis is the grind size represents the finest grind and represents the coarsest grind Note that the dynamic brewing pressure ranges from finest grind to coarsest grind However, the brewing time ranges from seconds finest grind to seconds coarsest grind Based on this figure, the perfect grind setting is either or where the brewing time is between and seconds and the dynamic pressure is between and BAR.
To help your get start in Coral, your boss gives you a starter code with a basic skeleton of brewCoffee function. Note that you need to complete the brewCoffee function by writing equations that compute factor and bias values.
Function brewCoffee integer grindSize returns integer brewTime
integer sPressure
float dPressure
float bias
float factor
sPressure
dPressure
bias
factor
Express the relationship between grindSize and dPressure as an equation. The equation should
include sPressure, grindSize, and factor that helps express the relationship of smaller
grindSize resulting in higher dPressure. Complete the equation below to compute factor as a function of grindSize.
factor funcgrindSize
As an example, you could set func as grindSize
factor grindSize
Obviously, this function doesn't work because when grindSize is
dPressure is also The correct factor should result in the highest
dPressure when grindSize is smallest. Modify the above equation to compute
factor.
Next, the function below calculate dPressure
dPressure sPressure factor
Next, since the relationship between the dPressure and brewTime is not linear, we need to
set up bias value as part of calculating brewTime. This can be done using
if elseif, and else statements. The idea here is to set the bias to a
value based on dPressure. A higher dPressure should result in a higher bias.
Ultimately, the brewTime is calculated by multiplying dPressure with bias
as shown later in the program.
Complete the code below to set the bias values based on dPressure values.
Below is a starter code. Simply remove the comment to execute the
code. Replace with code and numeric values. Note that you will likely need more cases
of elseif and else than provided.
if dPressure
bias
elseif dPressure
bias
else
bias
calculating brewTime
brewTime dPressure bias
output the results
Put grindSize to output
Put
to output
Put dPressure to output
Put
to output
Put brewTime to output
Put
to output
Function Main returns nothing
integer grindSize
grindSize Get next input
Put brewCoffeegrindSize to output
You can test your program by entering the following grindSize values, one at a time, in the Input window: and
Your espresso simulator should be as close as possible to the real behavior shown in the figure above. Slight variations are acceptable as long as the perfect shots are still within the ranges of BAR dynamic pressure and to seconds brewing time The maximum and minimum brewing times should be seconds and seconds, respectively. The maximum and minimum dynamic pressure should be BAR and BAR, respectively.
As the last step, you need to modify the Main function so that it can selfgenerate grindSize values. Currently, you need to enter the grindSize as an input for each run. Your task is to replace the line below with a for loop where the grindSize value is set automatically to iterate from to
grindSize Get next input
The following line should also be part of the new for loop.
Put brewCoffeegrindSize to output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
