How many iterations?
Where's the error?
Vocabulary
Structural Design
How do I code this?
100

for(int i = 0; i < 100; i++)

100 iterations

100

for(int i = 10; i > 0; i++)

Infinite Loop: i will never decrease

100

What is a method?

A segment of code with a name that can be called over and over again

100

Which loop would you choose for a program that fills the Comp Sci gradebook with a 100 for each student's grade?

For Loop

100

A for loop that repeats 5 times

for(int i = 0; i < 5; i++)

200

for(int i = 0; i <= 100; i++)

101 iterations

200

//assume that Scanner kb has been declared and initialized

SOP("Is this a loop?");

String answer = kb.nextLine();

while(answer.equals("yes")){

    SOP("This is a loop!");

}

Infinite Loop: answer never changes

200

What is a loop?

A segment of code that will be repeated based on a specific condition

200

Which loop would I choose for a robot that will continue to make cookies until my cookie jar is full?

While Loop


(Do/While - 50 points)

200

A method that takes one integer and returns that integer's cubed value

public static void cube(int x){

      return x*x*x;

}

300

x = 0;

while(x < 100){ 

      SOP ("This is a loop!");

      x+=5;

}

20 iterations

300

//assume Scanner kb has been declared and initialized

do{

    SOP("Is this a loop?");

    String answer = kb.nextLine();

} while(!answer.equals("no"));

Compile Time Error - scope of answer ends before while statement

300

access modifier

controls who can access the method

300

Which loop should I choose if I am writing a program for a robot that takes care of the "bottomless soft drink" orders at a restaurant?

Do/While


(While Loop - 50 points)

300

A while loop that executes only if the String variable answer is "yes"

while(answer.equals("yes"){

    //code here

}

400

int x = 0;

do{

     SOP("This is a loop!");

}while(x != 0);

1 iteration

400

public static void{

      //here is some code

}

Compile-Time Error: No Method Name!

400

parameter

the declared type and number of pieces of data a method can receive

400

What structure should I use if I need to print a set of instructions to the screen every time my user makes a mistake?

A void method


("Method" without "void" - 50 points)

400

a method that takes no parameters and returns nothing

public static void myMethod(){

     //code goes here

}

500

//assume Scanner kb has been declared & initialized

String answer = "";

do{

      SOP("Is this a loop?");

      answer = kb.nextLine();

} while (!answer.equals("yes");

As many iterations as it takes for the user to enter "yes", but it will run at least once

500

public static void myMethod(int x){

       return x * x;

}

Compile-Time Error: void methods cannot use return

500

argument

data that is being passed to a method through a method call
500

What structure would I use if I needed to frequently calculate the volume of different containers?

A method with parameters (return value)


(Method no specific details - 50 points)

500

A method that takes a String as a parameter and prints "best teacher" if the string is "Mrs. Nabors"

public static void myMethod(String s){

    if(s.equals("Mrs.Nabors"){

        SOP("Best Teacher!");

    }

}

600

//assume Scanner kb has been declared and initialized

SOP("Is this a loop?");

String answer = kb.nextLine();

if(answer.equals("yes")){

    while(!answer.equals("no")){

          SOP("Is this still a loop?");

          answer = kb.nextLine();

    }

}

0 iterations if the user does not enter "yes" the first time; at least one iteration if the user enters "yes" the first time

600

public static int myMethod(x){

     return x*x;

}

Compile-Time Error: Parameter needs a data type!

600

scope

the limitations of which part of code knows about a variable's value/existence

600

Which structure should you use if you need to give every student in the Comp Sci gradebook a score that is dependent on how many questions on a test they got correct?

for loop w/ if/else if/else or switch inside the loop

600

A method that takes an integer x and will print "This is the song that never ends" x times

public static void myMethod(int x){

    for(int i = 0; i < x; i++){

         SOP("This is the song that never ends"); 

    }

}

M
e
n
u