AP CompSci Quiz 3

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/15

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

16 Terms

1
New cards

frequently used static methods

floor(x) //returns a double; rounds x down

ceil(x) //returns a double; rounds x up

pow(x,y) //returns ?? x to the power y

abs(x) //returns ?? the absolute value of x?

sqrt(x) //??

round(x) //returns an int; ???

min(x,y) //???

max(x,y) //???

random() //returns double >????

2
New cards

use a ceiling return method

Scanner keyboard = newScanner??????

3
New cards

how are all Math functions static?

they are called directly with their class name, Math

???

4
New cards

System.out.printf()

formatted printing

2 parameters; how to format and what to format?

5
New cards

double dec and its output

6
New cards

System.out.printf(?????)

7
New cards

Math.random();

generates a random double from 0.0 up to but not including 1.0; random number in the range of [0.0, 1.0)

can cast as other things, like ints, ex: (int)(Math.random()*2 + 10) ints[10,12) //10 or 11 are the only possibilities //can’t just round using floor or ceil because that would still cast it as a double, would be __.0, even using round itself wouldn’t give equally likely outcomes -0 and 9 would be less likely

8
New cards

range of these

  1. Math.random()

  2. Math.random()*2

  3. Math.random()*5 + 1

  4. Math.random()*4 - 2

Math.random()*__ + __

  1. ??

  2. ??

  3. ??

  4. ??

Math.random()*range + minimum [0.0*rnage +min, ????]

9
New cards

how to generate a dice roll

??

10
New cards

where do you start for graphics? how do x and y go? give some examples

at the top left corner

x goes across

y goes down

window.fillOval(x, y, width, height); //?

window.fillRect(int x, int y, int width, int length);

11
New cards

parameter/argument

a channel used to pass information to a method.

//ex: setColor() is a method of the Graphics class that receives a Color

12
New cards

frequently used graphics methods

drawLine(a,b,c,d) //draws line starting at alb and going to c,d

drawRect(x,y,w,h) //????

fillRect(x,y,w,h) //????

setColor(x) //??

drawString(s,x,y) //??

drawOval(x,y,w,h) //??

fillOval(x,y,w,h) //??

drawArc(x,y,w,h,startAngle,arcAngle) //draws an arc at spot x,y that is w wide and h tall //startAngle specifies the start of the arc, arcAngle specifies the length of the arc?

fillArc(x,y,w,h,startAngle,arcAngle) //draws a filled arc at spot x,y rho is w wide and h tall //startAngle specifies the start of the arc, arcAngle specifies the length of the arc?

13
New cards

Rectangles in graphics (examples)

window.setColor(Color.BLUE);

window.fillRect(100,100,100,20);

window.setColor(Color.GRAY);

window.drawRect //????

????

14
New cards

Circles in graphics (examples)

window.setColor(Color.BLUE);

window.drawOval(100,50,40,40);

window.setColor(Color.GREEN);

???

???

15
New cards

arcs in graphics (examples)

window.setColor(Color.BLUE);

window.drawArc(100,100,40,40,90,90);

window.setColor(Color.GREEN);

window.drawArc(100,175,???)

???

???

16
New cards

Graphics Runner

public class GraphicsRunner extends JFrame

{

//variables not shown

public GraphicsRunner

????