5.2.1 Ghost Answer Key

Question: Stop light

Answer:

Question: Is It Even? Codehs Answers JAVA

var SENTINEL = 0;

function start(){

while(true){

var input = readInt(“Number: “);

if(input == SENTINEL){

println(“DONE!”);

break;

}

if(isEven(input)){

println(“Even”);

}else{

println(“Odd”);

}

}

}

function isEven(x){

return(x % 2 == 0);

}

Answer: Is it even

Question: Ghost

Answer:

Question: Draw

Answer: Draw Something Codehs Answers JAVA

function start(){

var line = new Line(1, 1, 2, 2);

line.setColor([Color.green](https://Color.green));

add(line); var circle = new Circle(30);

circle.setPosition(100, 50);

circle.setColor([Color.blue](https://Color.blue));

add(circle);

var rect = new Rectangle(200, 100);

rect.setPosition(60, 150);

rect.setColor([Color.green](https://Color.green));

add(rect);

}

Donation Page

Support Our Work

Do you appreciate the value this website provides? If so, please consider donating to help keep it running. Your donation will go a long way in helping us continue to provide the same quality of content and services. Every bit helps, and your support is greatly appreciated. Thank you for your generosity.