/ /Determine the costs of the blue beads.
double costPerBlueBead = 0.22;
int nrBlueBeads = 20;
double blueBeadCost = costPerBlueBead * nrBlueBeads;
/ /Determine the cost of the red beads.
double costPerRedBead = 0.33;
int nrRedBeads = 14;
double redBeadCost = costPerRedBead * nrRedBeads;
/ /Determine the cost of the thread
double costPerInchOfThread = 0.14;
double lengthOfThread = 24.0;
double costOfThread = costPerInchOfThread * lengthOfThread;
/ /Solve the original problem by making use of the
/ /solutions to the three main subproblems.
double totalCost = blueBeadCost + redBeadCost + costOfThread;
/ /Display result.
IO.print (``The total cost of materials is ``);
IO.print (totalCost);
IO.println ();
The Environment
costPerBlueBead ------ > 0.22
nrBlueBeads ------ > 20
blueBeadCost ------ > 4.4
costPerRedBead ------ > 0.33
nrRedBeads ----- > 14
redBeadCost ------ > 4.62
costPerInchOfThread ------ > 0.14
lengthOfThread ----- > 24.0
costOfThread ----- > 3.36
totalCost ------ > 12.38