review game 1. teams: b dylan, sarah, angie, chris s, isaac harrison, nikki, peter, katie, eddie...

37
Review Game 1

Upload: laurel-montgomery

Post on 29-Jan-2016

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

Review Game 1

Page 2: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

Teams: B• Dylan, Sarah, Angie, Chris S, Isaac• Harrison, Nikki, Peter, Katie, Eddie• Jen, Stephanie, Chris G, Trey, Megan• Joanna, John, Lexi, Spencer, Matt• Kevin, Browning, Draper, Tyler W• Ryan, Julian, Anders, Lara, Tyler Y

Page 3: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

Teams: C

• Jon H, Katy, Matt, Claire, Scott• Olivia, William, Christy, Nick, Ellie• Billy, Jade, Christina, Chris, Michael • Tommy, Stephanie, John V, Tim, Charles• Tatum, Collin, Evan, Drew, Pete• Nicole, Tyler, Steven, Wes, Aaron

Page 4: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

1.

• Describe what gets drawn:

fill(0,255,0);stroke(255,0,0);ellipseMode(CORNER);

ellipse(0,0,100,100);

Page 5: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

2.

• What is printed?

char a = ‘b’;

char b = ‘a’;

System.out.print(a);

Page 6: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

3.

• What is the value of number?

double number = (1/3)*3;

Page 7: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

4.

• What is the value of number?

int number = 3+2/5;

Page 8: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

5.

• What is the value of number?• int number = (int) 5.7;

Page 9: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

6.

• What word denotes the answer to a method?

Page 10: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

7.

• What line of Java declares and creates an object in the Student class with your name?

Page 11: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

8.

• Suppose I want to write a method to tell whether or not a number is positive.

• What would the input and output types be?

Page 12: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

9.

• Suppose I want to write a method that takes a letter and whether or not it should be upper case and computes the new letter.

• What should the input and output types be?

Page 13: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

10.

• What is special about a variable declared with the word “final”?

Page 14: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

11.

• What does this line of code do?

Tiger tony;

Page 15: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

12.

• What math allows us to tell the last digit of an integer?

Page 16: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

13.

• What is the difference between the setup() and the draw() methods?

Page 17: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

14.

• What is the value of b?

int x = 2;

int y = 4;

boolean b = (x<3) && (y<3);

Page 18: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

15.• What is the value of b?

int x = 2;

int y = 4;

boolean b = (x<3) || (y<3);

Page 19: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

16.

• What is the value of b?

int x = 2;

int y = 4;

boolean b = !(y<3);

Page 20: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

17.

• Which Java keyword means that a method has no output?

Page 21: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

18.

• What is the value of x?

int x = 17 % 6;

Page 22: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

19.

• What is the value of x?

int x = 6 % 17;

Page 23: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

20.

• What is the value of x at the end of the code?

int x = 3;

int y = 5;

x = y;

y = y+1;

Page 24: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

21.

• Suppose the Tiger class has this behavior:public int countTeeth()

What line of code calls the countTeeth behavior on the Tiger tony?

Page 25: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

22.

• Suppose the Tiger class has this behavior:

• public void grabMice(int mice)• What line calls the grabMice behavior

on the Tiger tony for 3 mice?

Page 26: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

23.

What is the error?

public int mystery(double a, double b){

if (a<b){

return a;

}

return b;

}

Page 27: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

24.

• What does this method do?

public int mystery(int a){

int answer = a%100;

return answer;

}

Page 28: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

25.• What is the error?

public int mystery(int a, int b){

if(a<b){

return a;

}else if (a>=b){

return b;

}

}

Page 29: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

26.What is x?

int a = 3;int b = 5;int x;if (a<b){

x = 0;}else if (b<10){ x = 1;}else{ x = 2;}

Page 30: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

27.What is x?int a = 3;int b = 5;int x;if (a<b){

x = 0;}if (b<10){ x = 1;}else{ x = 2;}

Page 31: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

28.

• Find and fix the error:

arc(100,100,100,100, PI, 0);

Page 32: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

29.

• What math tells you if a number is even?

Page 33: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

30.

• What is the difference?

System.out.println(str);

System.out.println(“str”);

Page 34: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

Round 2

Team

Page 35: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

Write a method

The above formula calculates a person’s BMI given their height in centimeters and weight in kilograms. Write a method to calculate a person’s BMI given their height and weight, but the weight is given in grams. (1 kilogram = 1000 grams).

public double bmi(double wt, double ht){

Page 36: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

Write a methodYou need to write a program to help out your weekend business doing lawn care. You really need to buy $15 bags of grass seed, but if any money is left over, you also need some $2 bags of mulch. Write a method that takes as input how much money you have and prints how many bags of grass seed and mulch I can buy. For example, if I have 52 dollars, I can buy 3 bags of seed (that’s $45) and 3 bags of mulch ($6 more).

public void purchaseOrder(int dollars)

Page 37: Review Game 1. Teams: B Dylan, Sarah, Angie, Chris S, Isaac Harrison, Nikki, Peter, Katie, Eddie Jen, Stephanie, Chris G, Trey, Megan Joanna, John, Lexi,

Write a method• The method takes as parameters the rate (amount per

hour) the employee makes and the number of hours worked. Employees make the pay rate for the first 40 hours they work, and overtime pay for any hours worked after that. Overtime pay is 1.5 times regular pay rate.

• For example, getPayAmount(10, 30) should return 300, and getPayAmount(10, 45) should return 475.

 • public double getPayAmount(double rate, double hours){