int i, j, k, m;
// some Java statements are omitted that assign values to i, j, k, & m.
// Your Java statement goes here
Create a single Java statement that assigns new values to i,
j, k, and m as follows (in the order indicated):
3. Given the applet skeleton below, fill in the paint method so that it renders the following picture:
In the picture, painting is inset 40 pixels from the left and the top. Each black square has an edge length of edg; there are num such squares on the diagonal and anti-diagonal (i.e., both diagonals).
public class test1 extends Applet
implements ActionListener, MouseListener
{
int num = 5, edg =
20, x, y;
boolean clicked = false;
Label
numL = new Label("Number:"),
edgL = new Label("Edge length:");
TextField numT
= new TextField("5", 2),
edgT = new TextField("20", 2);
public void init() {
add(numL); add(numT);
add(edgL); add(edgT);
numT.addActionListener(this);
edgT.addActionListener(this);
addMouseListener(this);
}
public void paint(Graphics
g)
{
//
Your code to paint the red and black squares goes here
//
Your code to process the mouse release goes here (see Question 4)
}
public void actionPerformed(ActionEvent
e) {
num = Integer.parseInt(numT.getText());
edg = Integer.parseInt(edgT.getText());
repaint();
}
public void mousePressed(MouseEvent
e) {}
public void mouseClicked(MouseEvent
e) {}
public void mouseReleased(MouseEvent
e)
{
x = e.getX();
y = e.getY();
clicked = true;
repaint();
}
public void mouseEntered(MouseEvent
e) {}
public void mouseExited(MouseEvent
e) {}
}
5. Give Java statements to produce the following "sum": Consider each number from 1 to 1000. If the number when divided by 10 has a remainder of 2, 3, 5, or 7, add the remainder to the sum. If the remainder is 0, 1, or 9, subtract the remainder from the sum. If the remainder is something else, add 1 to the sum. Your solution must use a switch statement to get full credit.