<!doctype html public "-//w3c//dtd html 4.0
transitional//en">
CS 476/576
Systems Programming
Fall 2006
Final Exam
Time 2 & 1/2 hours
Open Book & Notes
Name:
Login:
Please do NOT have any include statements in your
code.
Please be concise
and avoid any extraneous or unneeded statements in your code.
Question 1: (30 points)
Your programs in this question should be a
bare-minimum; you will be penalized for having any extra unneeded statements.
In addition, do not have: include statements, error checking statements.
Question 2: (35 points)
Write a Java/Swing
program that creates a N2 buttons labeled as:
1, …, N2
arranged
as NxN grid and the background of each
is green.
When the user clicks on any button (I, J)
all buttons in row I and all buttons in column J are disabled
and their background changes to red.
When all buttons are disabled a confirm dialog box appears for
the user to quit or restart. If the user chose not to quit, the interface is
restored back to its initial state. The default value of N is 10 and it
may be changed by specifying the new value as a command line argument.
Exemples:
% java q2
This creates a 10x10 grid.
% java q2 5
This creates a 5x5 grid.
Question 3: (35 points)
Write a Java application (not applet) program that creates N threads.
Each thread sleeps a random amount of time T <=N seconds,
increments an “accumulative” sleep counter by T, and terminates. The
last thread to terminate computes and prints the average sleep time among all threads.
The default value of N is 20 and it may be
changed by specifying the new value as a command line argument.
Exemples:
% java q3
The average sleep among the 20
threads: 10.5 seconds.
% java q3 5
The average sleep among the 5
threads: 2.7 seconds.