function start(){
for(var i = 0;i < 100;i++){
var roll = Randomizer.nextInt(1,6)
println("You rolled a " + roll)
}
}
Back
4.2.7: School's Out
Front
function start(){
var holiday = readBoolean("Is today a holiday? ");
holiday = !holiday;
var weekday = readBoolean("Is today a weekday? ");
var school = holiday || weekday;
println("Holiday: " + school);
}
Back
How many times will this program print "hello"?
var i = 50;
while (i < 100) {
println("hello");
}
Front
This code will loop infinitely
Back
4.10.5: Better Password Prompt
Front
var SECRET = "abc123";
function start(){
while (true)
var password = ("What is the password? ");
if (password == "abc123") {
break;
}
}
}
Back
How can we check if a variable num is even?
Front
(num % 2 == 0) will be true
Back
4.7.6: All Dice Values
Front
var SIDES_ON_DICE = 6;
function start() {
for(var i = 1; i <= SIDES_ON_DICE; i++){
for(var a = 1; a <= 6; a++){
println(i + "," + a)
}
}
}
Back
How many possible values can Randomizer.nextBoolean() return?
Front
2
Back
4.8.6: Random Color Square
Front
var SIDE_LENGTH = 100;
function start(){
var rect = new Rectangle(100,50);
rect.setPosition = Randomizer.nextInt(60,150);
rect.setColor = Randomizer.nextColor();
add(rect);
}
Back
4.2.6: Can You Graduate?
Front
function start(){
var isSenior = readBoolean("Are you a Senior?");
var hasCredits = readBoolean("Do you have enough credits?");
var canGraduate = isSenior && hasCredits;
println("Can I graduate " +
canGraduate);
}
Back
4.9.5: Fibonacci
Front
var MAX = 1000;
function start(){
var firstNum = 0;
var secondNum = 1;
println("1");
while (firstNum + secondNum < MAX){
var answer = firstNum + secondNum;
firstNum = secondNum;
secondNum = answer;
println(answer);
}
}
Back
What kind of statement allows us to run a block code only if a certain condition is true?
Front
if statement
Back
4.9.4: Inventory
Front
var STARTING_ITEMS_IN_INVENTORY = 20;
function start(){
var numItems = STARTING_ITEMS_IN_INVENTORY;
var numItems = STARTING_ITEMS_IN_INVENTORY;
while(numItems > 0) {
println("We have " + numItems + " in inventory.");
var buy = readInt("How many would you like to buy? ");
if (buy>numItems) {
println("There is not enough in inventory for that purchase.");
} else {
numItems -= buy;
println("We have " + numItems + " left.");
}
}
println("All out!");
}
Back
4.5.5: The Worm
Front
var NUM_CIRCLES = 15;
function start(){
for(var i = 0; i < 15; i++){
var circle = new Circle(NUM_CIRCLES);
circle.setPosition(i, 200);
circle.setColor(Color.grey);
add(circle);
}
}
Back
What statement can we use inside of a loop to end it?
Front
break
Back
4.7.4: Better Sum
Front
var MIN = readInt("What is the minimum number?");
var MAX = readInt("What is the maximum number?");
function start(){
var sum = 0;
for(var i = MIN; i <= MAX; i++){
sum += i;
}
println("The sum was " + sum);
}
Back
4.3.5: Rolling Dice
Front
function start(){
var diceOne = readInt("First Dice Roll? ");
var diceTwo = readInt("Second Dice Roll? ");
var rolledDoubles = diceOne == diceTwo;
println("Got Doubles: " + rolledDoubles);
}
Back
4.7.5: Factorial
Front
var N = 5;
function start(){
var MIN = 4;
var MAX = 15;
var product = 4;
for(var i = MIN; i <= MAX;i++){
product *= i;
}
println("The product was " + product);
}
Back
4.5.4: Meme Text Generator
Front
function start(){
for(var i = 0; i < 50; i++){
println("I will not come to school late.");
}
}
Back
What symbol represents the and operator in JavaScript?
Front
&&
Back
How many times will the following program print "hello"?
for (var i = 0; i < 5; i++) {
println("hello");
}
Front
5
Back
How many times will this program print "hello"?
var i = 10;
while (i > 0) {
println("hello");
i--;
}
Front
10
Back
What symbol represents the or operator in JavaScript?
Front
||
Back
What is the term for the value that signals the end of user input?
Front
sentinel
Back
4.10.4: Snake Eyes
Front
function start(){
while(true) {
var roll1 = Randomizer.nextInt(1,6);
var roll2 = Randomizer.nextInt(1,6);
if (roll1 && roll2 == 1){
break;
}
println("You rolled: " + roll1 + ", " + roll2);
}
}
Back
Why do we use constant variables?
Front
All of the Above
Back
After the following code runs, what is the value of isWeekend?
var isSaturday = true;
var isSunday = false;
var isWeekend = isSaturday || isSunday;
Front
true
Back
What is the proper operator for "not equals" in JavaScript?
Front
!=
Back
How many times will the following code print "hello"?
for (var i = 3; i < 8; i++) {
println("hello");
}
Front
5 **YES AGAIN
Back
In the following code, what will be the last number to print to the screen before the program finishes?
for (var i = 0; i < 10; i++) {
if (i % 2 == 0) {
println(i);
} else {
println(2 * i);
}
}
Front
18
Back
How many times will the following code print "hello"?
for (var i = 0; i < 8; i += 2) {
println("hello");
}
Front
4
Back
What is the proper way to compare if two values are equal in a boolean expression in JavaScript?
Front
==
Back
What will be the value of sum after this code runs?
var START = 1;
var END = 4;
function start(){
var sum = 0;
for(var i = START; i <= END; i++){
sum += i;
}
}
Front
10
Back
Which of the following returns a random number between 1 and 10?
Front
Randomizer.nextInt(1, 10)
Back
Which of the following is not a valid value for a boolean?
Front
yes
Back
4.6.5: Count By Sevens
Front
function start(){
for(var i = 0; i <= 500; i += 7){
println(i);
}
}
Back
What kind of statement allows us to run one block of code if one condition is true, and a separate block of code otherwise?
Front
if/else statement
Back
4.4.7: Teenagers
Front
function start(){
var age = readInt("Age: ");
if(age == 15){
println("Yes, you are a teenager.");
}else{
println("No, you are not a teenager.");
}
}
Back
4.3.6: All Star
Front
function start(){
var pointsPerGame = readInt("Points per game? ");
var reboundsPerGame = readInt("Rebounds per game? ");
var assistsPerGame = readInt("Assists per game? ");
var isAllStar = pointsPerGame >= 25 || pointsPerGame >= 10 && reboundsPerGame >= 10 && assistsPerGame >= 10;
println("Is all star? " + isAllStar);
}
Back
4.4.8: Meal Planner
Front
function start(){
var vegetarian = "Vegetarian";
var lactose = "lactose intolerant";
var restriction = readLine("Restriction: ");
if(restriction == "vegetarian"){
println("Vegetarian: Veggie burger");
}
if(restriction == "lactose"){
println("Lactose Intolerant: No Cheese");
}
if (restriction == "none"){
println("No restrictions: No alterations");
}
}
** IF THIS DOESNT WORK JUST RELOAD THE PAGE AND TRY AGAIN!!
Back
4.1.4: Do You Have a Cat?
Front
function start(){
var myBoolean = true;
var anotherBoolean = false;
println(" Do You have a cat? " + true);
}
Back
4.6.6: Powers of Two
Front
function start(){
for(var i = 1; i <= 1000000; i *= 2){
println(i);
}
}
Back
4.5.6: Caterpillar
Front
var NUM_CIRCLES = 15;
function start(){
for(var i = 0; i < 15; i++){
var circle = new Circle(NUM_CIRCLES);
if (i % 2 == 0) {
circle.setPosition(i, 200);
circle.setColor(Color.red);
add(circle);
} else {
circle.setPosition(i, 200);
circle.setColor(Color.green);
add(circle);
}
}
}
Back
Which of the following is a good example of a proper constant variable name?
Front
var MAX_VALUE = 100;
Back
Which of the following is correct loop and a half structure?