Make sure review the four homework assignments, all of the labs we've done, and the examples we've written in class.
ExamOne
that
prints Hello World
to the console.
ExamOne
that prints Hello World
in the center of a 600-by-600 picture.
int count = 0; int age; DOuble pi = 3.14159; String myname = "Poindexter; int the answer = 9;
StdOut.println("What do" + 1 + (2 + 3) + 4 + " I print?");
***** ***** ***** ***** *****
* ** *** **** *****
int sum = 0; for (int i = 7; i < 12; i=i+2) { sum = sum + i; } StdOut.println(sum);
int x; x = 1/3; StdOut.println(x);
______________________________________________ public class Exam1 ______________________________________________ public static void main (String args) { ______________________________________________ int XXXX = 7; ______________________________________________ int pi = 3.14159; ______________________________________________ StdOut.println(XXXX); ______________________________________________ Picture p = new Picture(); ______________________________________________ Graphics g = getGraphics(); ______________________________________________ g.fillOval(XXXX, XXXX*100, 20); ______________________________________________ int sum = 0; ______________________________________________ for (int i = 0; i < 10; i++ { ______________________________________________ sum = sum + I ______________________________________________ } ______________________________________________ StdOut.println(sum); ______________________________________________ } ______________________________________________ ______________________________________________
int sum = 0; for (int i = 4; i < 9; i++) { sum = sum * i; } StdOut.println(sum);
myint
and give it the value 127.
Picture p = new Picture(200,200); Graphics g = p.getGraphics(); g.setColor(Color.black); g.fillRect(0,200,50,50); p.repaint();
The answer is not because we forgot the import
statement or
main
program. Assume that all that stuff is there and works.
20.6
.
rint
in the Math class).
For example, if I entered 33, 12, and 17 your code should print 20.7
.
x
, y
, theta
, and
length
are all declared to be integer variables.
Write a Java code snippet that draws a red line that
starts at point (x,y)
, is theta
degrees
from horizontal, and is length
pixels long. (Hint: recall the clock
example we did in class). Use the picture below as a guide.
hello count 5times void pepper2 iden_tifier APPLES "x" do-it
int x = 7; int y = 9; int z = x + y / 4 * (x - 2); StdOut.println(z);