PRO404 Java Programming

advertisement
PRO404 Java Programming
FINAL EXAMINATION
2 hours
Note: This is an open-book examination.
Each question is worth 20 marks.
1. A company pays its employees as:
- hourly workers, who receive a fixed hourly wage for up to the first 40
hours they work and 1.5 times their hourly wage for overtime hours;
- commission workers, who receive $500 plus 5.7% of their gross weekly
sales;
- pieceworkers, who receive a fixed amount for each item they manufacture.
Write a stand-alone Windows-style application which produces the weekly
salary for each employee. In the main frame the user has to choose between
the 3 types of employees by clicking on one of the 3 buttons shown in a
vertical column. The user then sees a frame or a dialog box containing the
appropriate labels and textfields for the type of employee selected. After
entering data the user clicks on a "Submit" button to calculate and
display in a textfield the weekly salary. Another button labeled "Go to
main" allows the user to return to the main frame.
2. Write and applet which bounces a blue ball inside an applet. The ball
should be initiated with a mousePressed event. When the ball hits the edge
of the applet the ball should bounce off the edge at a randomly selected
angle (any angles are OK) and the applet plays the sound file "hi.au"
stored on the hard disk in the folder "Sounds". The key feature in this
applet is the randomness of the bounce. Also, make sure that you use
double-buffering in producing this animation.
3. Write a stand-alone Java network server application which
will accept connection from one client at a time on port
number 2233. When a client connects to the server,
the server will first get a file name in the connection,
followed by the content of the file and a string "****END****"
to indicate transfer completed. The server at that point
should close the connection to the client. The contents of the
file received from client, should be stored by the server on
the machine in text format to the file name received from the
client.
Download