Problem Statement:
Click "Run" to run the code and answer the prompt. Every time you get the answer correct, an ornament will pop up on the tree (blue one if your answer is even and red if your answer is odd). You should have 5 ornaments at the end of the program. Refresh for more problems.
/* Code generated by RoboBlockly v2.0 */
/* Problem Statement:
Click "Run" to run the code and answer the prompt. Every
time you get the answer correct, an ornament will pop up on
the tree (blue one if your answer is even and red if your
answer is odd). You should have 5 ornaments at the end of
the program. */
#include <chplot.h>
CPlot plot;
// Describe this function...
void ornament(double x, double y, double oe) {
if (oe == 1) {
plot.noStrokeColor();
plot.fillColor("#990000");
plot.ellipse(x, y, 2.9, 2.6, -15);
plot.fillColor("red");
plot.circle(x, y, 1.2);
plot.strokeWidth(3);
plot.strokeColor("#cccccc");
plot.line(x, y + 0.5, x, y + 1.7);
}
else {
plot.noStrokeColor();
plot.fillColor("blue");
plot.ellipse(x, y, 2.9, 2.6, 15);
plot.fillColor("#33ffff");
plot.circle(x, y, 1.2);
plot.strokeWidth(3);
plot.strokeColor("#cccccc");
plot.line(x, y + 0.5, x, y + 1.7);
}
}
// This is a sample solution:
printf("17+16=33 Odd");
ornament(17, 16, 1);
delaySeconds(0.03);
printf("20+30=50 Even");
ornament(20, 30, 2);
delaySeconds(0.03);
printf("5+9=14 Odd");
ornament(6, 9, 2);
delaySeconds(0.03);
printf("29+12=41 Odd");
ornament(29, 12, 1);
delaySeconds(0.03);
printf("22+22= 48 Even");
ornament(22, 22, 2);
plot.grid(PLOT_OFF);
plot.axisRange(PLOT_AXIS_XY, 0, 36);
plot.ticsRange(PLOT_AXIS_XY, 6);
plot.sizeRatio(1);
plot.plotting();