PERMANENT STORAGE PAGE 1 OF 6 MR.
WACHS: COMPUTER SCIENCE 40S
PERMANENT STORAGE ASSIGNMENT
COMPUTER SCIENCE – GRADE 12
DESCRIPTION:
Assignments for the grade 12 Computer Science course will be more open ended and (hopefully) creative than the
problem set given in previous grades
In grade 10, you did the specific problems I set out for you (problem 1, problem 2, etc.)
In grade 11 you had more choice from a collection of problems to do whichever problem(s) you felt was best for your
learning
Now, in grade 12, you will have even more choice as now I mostly want you to design your OWN problem(s) to
demonstrate your learning to me on the specific unit content
DETAILS:
You should design your own programming problem to demonstrate the specific learning outcomes for this unit (see
below)
The problem may have a specific purpose (like a hypothetical company you are programming for) or just simple unit
content examples
You may design one problem to demonstrate the unit learning outcomes, or several
You may make the problem have a simple input/output system (e.g. [Link]() and Scanner
input, or simple JOptionPane dialogs) or a more complex GUI
You may even carry one problem over unit to unit expanding on it each time to demonstrate the unit learning
outcomes and resubmitting it with its modifications for marking after each unit (this may even be incorporated into your
final project)
Options: if you do not wish to make programming problems, you may demonstrate your learning in these other ways:
- Review notes: create a set of study notes for the unit either by hand or typed - do not just recopy my notes,
but create summary notes
- Video Tutorials: create a video screencast tutorial example(s) of how to learn the specific learning
outcomes for the unit and upload this to youtube (or give Mr. Wachs the video file) – if you are unsure how to
do this, please see Mr. Wachs for suggestions for software, etc.
MARKING:
I will use the same marking rubric matrix that I used through grade 10 and expanded on through grade 11
This includes all eleven domains in: problem solving, commenting, design, data structures, algorithms, methods, style,
usability, error handling, success, and holistic approach
The mastery factor I will apply will be dependent on the problem(s) you design and will increase or decrease based on
factors like:
- How many unit learning outcomes you demonstrate (breadth of knowledge)
- How complex your demonstration of learning outcomes is (depth of knowledge)
- How detailed your overall solution is in terms of size (lines of code), design, and practicality (usability, realism,
etc.)
- How creative your
problem(s) are
PERMANENT STORAGE THURSDAY, DECEMBER 17, 2015 MR. WACHS: COMPUTER SCIENCE 40S
PERMANENT STORAGE PAGE 2 OF 6 MR. WACHS: COMPUTER SCIENCE 40S
UNIT LEARNING OUTCOMES:
Your problem(s) that you designed for this unit should demonstrate the following:
1. Students can use the FileReader and FileWriter classes effectively in conjunction with the
PrintWriter and BufferedReader and/or FileOutputStream, FileInputStream,
ObjectOutputStream, ObjectInputStream classes
2. These classes are implemented inside a proper try catch block
3. The use of the print(), println(), readLine(), read(), writeObject(), readObject()
and close() methods to read and write text (either by line or by character) and/or objects to a file
4. Use of the File class and some of its methods
5. Use of the JFileChooser class and some of its methods
6. Use of the Serializable interface
SUGGESTIONS:
If you are stumped for ideas on how to implement a problem and solution for demonstration of this unites learning
outcomes, the following are suggestions for ideas that you could use, or expand on (however, these are in no way
mandatory)
1. Write a program which opens 2 text files simultaneously, and reads each line by line comparing file 1 with file 2.
After reading through both files, the program will output whether or not the 2 files are identical (meaning every line
from one file is in every line of the other)
2. Write a program that gets two words from a user: a “From” word, and a “To” word, and then opens a text file
and writes it to a second text file, but replaces every incident of the “From” word with the “To” word, for example:
User enters “cat” and “rat”
The original text file:
The cat sat on the mat. What a catty cat to sit on his cat mat.
The second text file:
The rat sat on the mat. What a catty rat to sit on his rat mat.
3. The Create your own version of Windows Notepad that contains many of the same elements that the real Notepad
has. Your Notepad should include menus that allow the user to Save, Open, create a new document, Exit, and get
help. Code each menu event to respond appropriately for each action. When Save or Open are clicked, an input
box comes up asking the user for the file name (with a default name already inside). As well, when a file is open,
the files name should be
displayed in the caption of
the form. The help menu
will bring up a message
box containing some
simple instructions on
using your Notepad. Try to
get the design of your
Notepad to match the
actual Notepad as closely
as possible.
PERMANENT STORAGE THURSDAY, DECEMBER 17, 2015 MR. WACHS: COMPUTER SCIENCE 40S
PERMANENT STORAGE PAGE 3 OF 6 MR. WACHS: COMPUTER SCIENCE 40S
4. If anyone took Computer class with Mr. Wachs in grade 9, then you know the ‘best’ way to create web pages is to
edit the code with Windows Notepad. However, some students complained that this incredibly complex program
was insufficient for
web page editing.
In this assignment,
you will be re-
creating this
program with a
‘new’ look,
interface, and
features! For
example, a
common mistake
when coding web
pages is to leave a
‘tag’ unclosed. In other words, you make an opening tag (e.g. <center>, but then don’t bother to close it with
</center>). Write a program that reads a web page file into a text box, while examining the text from that file
as it’s read in. If a “<” is read, the program reads the next character, if it’s a “/” then it is known to be a closing tag,
if the next character read is a “!” the tag is known to be a comment tag. Otherwise it is an opening tag. The program
will read all other characters normally. The program will keep track of the types of tags for statistics. Use the
NetBeans GUI editor to create buttons across the top of the form for: New, Open, Save, Validate, and Exit. These
buttons will perform the appropriate action.
5. Your mother is quite upset that you constantly forget her birthday. To correct this, you will create a birthday
database application that writes a list of
birthday records to a file. Clicking the add
button will bring up two input boxes asking
for the name and birthday, this data will be
added to the end of the text file containing all
the records. Clicking the two arrow buttons
will arrow the user to scroll through all the
records (without going past the end of any
records). Also the two text boxes should be
disabled so the user cannot click inside them.
6. Your previous customer, the “We Save 4 Ya” bank has expanded nation wide. However, they have yet to
synchronize all their computer systems. Some branches are using Windows machines, some Macs, and some are
using Unix systems. In order to communicate electronically, they have commissioned you to create a method
(which will be incorporated into a larger system), which will read a simple text file (which can be sent in any
system) and read and make the appropriate changes to the customer database. The results will then be saved to
another file (a report file) to track results. Your program will be a simple driver form which simply tests this sub-
routine (e.g. a form with one button called “Test”). Your program will read from an input file a series of transactions
and perform an appropriate action. Each customer has a customer name, and account balance. Legal transactions
are:
- addcust cust_name → customer name “cust_name” is added to the database with no account balance
(note: the name consists of a single word, where underscores _ represent blanks
PERMANENT STORAGE THURSDAY, DECEMBER 17, 2015 MR. WACHS: COMPUTER SCIENCE 40S
PERMANENT STORAGE PAGE 4 OF 6 MR. WACHS: COMPUTER SCIENCE 40S
- addcust cust_name balance → Append the balance data amount to cust_name’s record
- printtrans cust_name → will print the customer name and account balance, if no cust_name is given,
all customers in the database are printed
- delcust cust_name → delete customer cust_name and balance from the database
Each transaction should be echoed (i.e. print out the details nicely in the report file). For example, if the input file
contains:
addcust Larry_Wachs
addtrans Larry_Wachs 2000.50
addtrans Larry_Wachs -1000
printtrans Larry_Wachs
addtrans Larry_Wachs 9.50
printtrans Larry_Wachs
addcust Bill_Gates
addtrans Bill_Gates 20000.00
addtrans Bill_Gates 945.25
addcust Peter_Parker
addtrans Peter_Parker 57.39
printtrans Peter_Porker
printtrans
delcust Bill_Gates
printtrans Bill_Gates
printtrans
The output file (report file) should look like this:
Adding customer Larry_Wachs to the database.
Adding transaction 2000.50 to customer Larry_Wachs.
Adding transaction -1000 to customer Larry_Wachs.
Customer: Larry_Wachs has a current balance of: 1000.50
Adding transaction 9.50 to customer Larry_Wachs.
Customer: Larry_Wachs has a current balance of: 1010.00
Adding customer Bill_Gates to the database.
Adding transaction 20000.00 to customer Bill_Gates.
Adding transaction 945.25 to customer Bill_Gates.
Adding customer Peter_Parker to the database.
Adding transaction 57.39 to customer Peter_Parker.
Customer: Peter_Porker customer not in database.
Balances of all customers in database:
Larry_Wachs: 1010.00
Bill_Gates: 20945.25
Peter_Parker: 57.39
Deleting customer Bill_Gates from the database.
Customer: Bill_Gates customer not in database.
Balances of all customers in database:
Larry_Wachs: 1010.00
Peter_Parker: 57.39
7. Mr. Wachs enjoys writing articles for ‘meanest teachers monthly’ magazine, but his editor is always upset at him
because he submitts his article in ragged format. The editor would like the text in justified format. The difference is
explained here:
PERMANENT STORAGE THURSDAY, DECEMBER 17, 2015 MR. WACHS: COMPUTER SCIENCE 40S
PERMANENT STORAGE PAGE 5 OF 6 MR. WACHS: COMPUTER SCIENCE 40S
The large brown cow sat on the The large brown cow sat on the
blue mat. My cat’s favorite toy is blue mat. My cat’s favorite toy is
a piece of ham. I love to mow my a piece of ham. I love to mow my
lawn in the rain but not the snow; lawn in the rain but not the snow;
I guess I’m just weird that way. I guess I’m just weird that way.
The time of day is not as The time of day is not as
important as the time of year. important as the time of year.
Ragged text does not align along the right side Justified text aligns exactly each line (except the
last line of a paragraph) along the right side
As well as having the text The large brown cow The large brown cow sat on the blue mat.
justified, my editor needs the text sat on the blue mat. My cat’s favorite toy is a piece of ham.
My cat’s favorite toy I love to mow my lawn in the rain but
fit inside a 40 character width. is a piece of ham. I not the snow.
Please write a Java program that love to mow my lawn
in the rain but not
I guess I’m just weird that way. The
time of day is not as important as the
reads in a text file ([Link]) the snow. time of year.
then writes the text back out to a I guess I’m just 1234567890123456789012345678901234567890
weird that way. The
text file ([Link]) in the time of day is not as
important as the time
proper format for the editor. For of year.
example:
8. A computer repair shop has determined that the major cause of many problems with today’s computers is the over
use of the “space bar.” In an attempt to gather statistics to prove this, they have commissioned you to create an
application that reads in text files, then processes the data it reads to determine how many times a space bar was
pressed in the creation of that document. The results will not only be shown, but they will be shown as statistics.
The contents of
the text box will
be rewritten so
that when a
space is read, a
<S> will be put
into the text box,
when a Line Feed
is read a <L>,
and a <C> for a
carriage return.
Keep track of when a space is read, or when a normal character is read. Once the file is read the statistics are
displayed. Also code a button to read the file normally into the text box.
9. Write a program which reads the information from the table below to a sequential text file called “[Link]” and
then writes a text file called “[Link]” which the teams are written in descending order by the percentage of games
won:
Team Won Lost
Boston 88 74
Winnipeg 85 77
Toronto 53 109
New York 92 70
Los Angeles 74 88
PERMANENT STORAGE THURSDAY, DECEMBER 17, 2015 MR. WACHS: COMPUTER SCIENCE 40S
PERMANENT STORAGE PAGE 6 OF 6 MR. WACHS: COMPUTER SCIENCE 40S
10. Write a program which reads a text file of names in the format below:
Johann Sebastian Bach
George Fredric Handel
Carl Phillip Emmanuel Bach
Joseph Haydn
Johan Christian Bach
Wolfgang Amadeus Mozart
And then write the names to a second text file, but in this format:
Bach, Johann S.
Handel, George F.
Bach, Carl P. E.
Haydn, Joseph
Bach, Johan C.
Mozart, Wolfgang A.
11. Write a “mad libs” program which reads three text files: “[Link]” which contains a set of sentences in
formats similar to this:
Dave Smith’s job is to VERB all the NOUN
Sara Smile wanted to VERB with her NOUN
Etc.
Where the words VERB and NOUN are just placeholders. Then the text file “[Link]” contains a list of verbs like:
run
display
eat
Etc.
And finally, the text file “[Link]” which contains a list of nouns like:
banana
elephants
vegetable
spider-man
etc.
The program will write a text file called “[Link]” which contains a copy of the sentences from the
“[Link]” file, but has replaced the placeholders with a random verb and noun from those text files in each
case like below:
Dave Smith’s job is to display all the elephants
Sara Smile wanted to eat with her spider-man
Etc.
PERMANENT STORAGE THURSDAY, DECEMBER 17, 2015 MR. WACHS: COMPUTER SCIENCE 40S