几道作业题目据说是剑桥大学研究生一年级的作业
G6DICP 2 Tim Brailsford, October 2003.
Task A (10% Marks)
Write a program called cw1a (ie the main method will be in a class called “cw1a”). This program should
print out the title banner for the coursework and your name as shown below.
|-------------------------------------------------
| G6DICP Coursework 1 - FizBuz Simulator
| by <Your name goes here>
|-------------------------------------------------
Task B (30% Marks)
Write a program called cw1b . This program should print out the title banner and then print out a table
containing numbers 1-100. Your program should use loops to achieve this, and the output will look similar
to that shown below.
|-------------------------------------------------
| G6DICP Coursework 1 - FizBuz Simulator
| by <Your name goes here>
|-------------------------------------------------
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 100
Task C (35% Marks)
Write a program called cw1c. This program should print out a table similar to that of task B, but instead of
the number, numbers divisible by 5 will be replaced by “Fiz” and numbers divisible by 7 will be replaced
by “Buz”
Task D (25% Marks)
Write a program called cw1d. This program should print out a table similar to that of task C, but “Fiz”
should also be used to replace numbers that contain a 5, and “Buz” should also be used to replace numbers
that contain a 7 (nb this is in addition to replacing the numbers divisible by 5 and 7). Finally draw a neat
box around your table.
Task E
Document your code by writing instructions explaining how to run it, listing all of the files you have
submitted, and specifying any limitations (eg you might want to say what platforms you would expect it to
run on, and what platforms you have tested it on). This document should be written as a plain text file (ie
ASCII – MS Word binary files are not acceptable) – and this file should be called README.TXT.
This, together with the comments in your source code, will constitute your documentation. There will be
marks in each task for documentation – which is why a specific allocation isn’t given here.
G6DICP 3 Tim Brailsford, October 2003.
Coursework Submission
The submission procedure will be the same for all three courseworks – so it is well worth getting it right
now! If you get this wrong, then you might loose some (or even all) of the marks for that coursework. We
do not gratuitously penalize trivial mistakes in the submission procedure, but failing to follow these
instructions could cause your work to get lost or to be misunderstood by a marker. If that happens then it is
your problem, not ours!
1. important that you follow these instructions exactly because parts of the submission and administration
process are automated.
2. Prepare your files for submission. Compile your programs, and place both the source code and
binaries for each task into a directory called, taskA, taskB, taskC and taskD respectively (the
README.TXT file should not be in a directory, since this is applicable to all tasks).
Assuming that you have used a single class per program, you should have the following files:
cw1/README.TXT
cw1/taskA/cw1a.java
cw1/taskA/cw1a.class
cw1/taskB/cw1b.java
cw1/taskB/cw1b.class
cw1/taskC/cw1c.java
cw1/taskC/cw1c.class
cw1/taskD/cw1d.java
cw1/taskD/cw1d.class
3. Your source code should contain a comment at the top in the format shown below - modified to
contain your name and username (not mine!).
/**
* Author : T.J. Brailsford
* Date : 3/10/03
* Module : G6DICP
* Title : ICP Coursework 1
* SCSiT Username : tjb
*/
4. Compress all of these files into a single ZIP archive – preserving the directory structure. Name the zip
file as your username, and the coursework number. For example, if your username is tjb03m and this
is coursework 1 then name the file tjb03m-cw1.zip.
5. Attach your zip file to a single e-mail, which you should send to an address that will be provided by
the submission deadline. At the time of writing this address is not available – it will be posted on the
module web site before the submission deadline – please wait for this DO NOT SEND
COURSEWORK DIRECTLY TO ME!
The Subject field should contain the text "ICP-CW1" followed by your last name, and then your
initials. For example - my submission would be:
ICP-CW1 BRAILSFORD, TB
If your name is Colin Coder, then the subject field of your submission should be:
ICP-CW1 CODER, C
Do not include any text in the body of your e-mail – submissions are batch processed - they won't be
read!! If you need to include any explanatory notes, then please place them as comments in your
source code -underneath the heading comment described above. After submitting the work you should
receive a confirmation of receipt. If you don't get this (allow some time - it is usually almost instant,
but it could take over an hour), then first check that the address you used is correct, and then failing
that contact me (Tim.Brailsford@nottingham.ac.uk).
6. University e-mail systems (usually SCSiT) should be used for submission of work. DO NOT use
outside systems such as Hotmail. At times of high traffic these systems can be unreliable for mail with
attachments, and loosing coursework in Hotmail will not be considered an excuse for non-submission
or late submission!
NOTE for people who want to e-mail from home. The SCSiT e-mail system is accessible from outside
the Nottingham domain – you can access your account from anywhere in the world. This is supported by
TSG, and details of how to configure your mailer are available on the TSG web site. You are very strongly
advised to use university mail services (either SCSiT or IS) for all university business.
Hints
1. You should always develop your programs in stages – the tasks here are designed to help you to do
this.
2. Leave the box around the output until everything else is working – it is much easier if this is the last
apect of the program that you implement.
3. Use a nested loop for task B.
4. Implement the Buz functionality on its own at first. When this is working, then implementing Fiz will
be identical – you just change a 5 into a 7. If you design your code carefully, you could even use
exactly the same code for both.