Question 1
(a)3pts

(b)7pts

Question 2
2 pts each. 10 pts.
Step1 : SSC
Step2 : SSCNNN, add NNN from step 2
Step3 : E
Step4: E, same as step 3.
Step5: SENN
Question 3
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class OddEven extends JFrame implements ActionListener {
JButton[] buttons = new JButton[15];
JLabel label = new JLabel();
Container contentPane = getContentPane();
public OddEven() {
contentPane.setLayout(new GridLayout(4,4));
for(int i = 0; i < 15; i++) {
buttons[i] = new JButton(Integer.toString(i));
buttons[i].addActionListener(this);
contentPane.add(buttons[i]);
}
// points should not be taken off is the student does not set the alignment
label.setHorizontalAlignment(JLabel.CENTER);
contentPane.add(label);
}
public void actionPerformed(ActionEvent e) {
int num = Integer.parseInt(e.getActionCommand());
if(num%2 == 1) {
label.setText("Odd");
} else {
label.setText("Even");
}
}
public static void main(String[] args) {
JFrame f = new OddEven();
f.pack();
f.setVisible(true);
}
}