CS139
Algorithm Development
|
Software
Requirements Specification
Programming Assignment 2
Tools
Due Tuesday, October 11th by 11:00pm
Hardcopy Due Wednesday, October 12th by class time
Introduction
Purpose: You have written enough code now to begin
to see some patterns in what you need to do. For example, when
reading in a value from the keyboard, you prompt, read the value and
display the new line character. This program is the start of a toolkit that you can use with any future programming assignments or labs. Some of the String manipulation methods will be used in PA3 (See Chapter 10 for some handy methods).
Objectives - At the
conclusion of this exercise the student will demonstrate that they can:
- Use both value returning and void methods.
- Precisely follow specifications for methods.
- Use a generic driver to "exercise" your programs.
- Do everything necessary to
create, debug, and run a java program.
- Use comments to delineate
each section of the program.
- Adhere to a Style Guide.
- READ
AND FOLLOW DIRECTIONS!!!!!
Deadlines
- Submit: October 11th, 2011
by
11:00pm.
- Report: October 12th, 2011
at
the beginning of class. A late penalty will apply for
each of the 2 deadlines. If the submit is late, the report is due the
next class or lab session day after successful submission.
Programs will not be accepted after 7 days late.
Prerequisites
You have covered the material
in Chapter 5 of Gaddis.
Program
Behavior
The driver program, ToolkitTester.java,
contains a main method that will create a
new Toolkit object, run each of its methods,
and produce output that indicates whether your methods conformed to the
expected behavior. Method headers containing the name of the
method, input parameters, and return type are found in the file, Toolkit.java.
Toolkit Methods
- getInteger - This method will take in
a Scanner object and a String prompt, (in that order), display the prompt, read
in the value from the keyboard, and output a newline character. This method should consume the newline character.
- getDouble - This method will take in
a
Scanner object and a String prompt, (in that order), display the prompt, read in the value
from the keyboard, and output a newline character. This method should consume the newline character.
- getToken - This method will take in a Scanner object and a String prompt, (in that order), display the prompt, read in the value from the keyboard, and output a newline character. This method will read in only the next token (set of characters before a white space character).This method should consume the new line character.
- getLine - this method will take in a Scanner object and a String prompt, (in that order), display the prompt, read in a whole line from the keyboard, and output a new line character.
- getEID - This method will take in three String objects representing last name, first name, and middle name (in that order) and returns an e-id consisting of the first 6 characters of the last name, the first initial and the middle initial. So for example, if I passed Harris, Nancy, Lea the method would return harrisnl. You can assume that each last name will be equal to or larger than 6 characters. (HINT: See a helpful method lower in the list).
- getInit - This method will take in three String objects representing last name, first name, and middle name (in that order) and returns the initials, in first, middle, last order. So if I passed Harris, Nancy, Lea this method would return NLH.
- makePluralS - This method will take in a String and return that String with an 's' appended to the end. If I called this method with "textbook", the method would return "textbooks".
- makePluralIes - This method will take in a String and return that String with the last letter removed and an 'ies' appended to the end. So for example, if I sent in the String, "body", this method would return "bodies".
- capitalize - This method will take in a String and capitalize the first letter of the String. For example, if I sent in the String "penguin", the method would return "Penguin".
- makeSmall - this method will take in a String and make the first letter of the String a lower case. For example, if I sent in the String "Penguine", the method would return "penguin".
Examples
Method call (assumes a Toolkit
object named bob, and a Scanner named kb) |
Display |
Input (for get methods) |
Return value |
bob.getInteger(kb, "Enter an integer: "); |
Enter an integer:
|
5 |
5 |
bob.getDouble(kb, "Enter a double number: "); |
Enter a double number: |
5.75 |
5.75 |
bob.getDouble(kb, "Enter a double number: "); |
Enter a double number: |
5 |
5.0 |
bob.getToken(kb, "Enter a word: "); |
Enter a word: |
something |
"something" |
bob.getToken(kb, "Enter a word: "); |
Enter a word: |
something else entirely |
"something" |
bob.getLine(kb, "Enter a message: "); |
Enter a message: |
This is silly |
"This is silly" |
bob.getEID("Bulldog", "Duke", "The"); |
|
|
"bulldodt" |
bob.getInit("Bulldog", "Duke", "The"); |
|
|
"DTB" |
bob.makePluralS("chair"); |
|
|
"chairs" |
bob.makePluralIes("butterfly"); |
|
|
"butterflies" |
bob.makePluralIes("chainsaw");
NOTE: this doesn't make sense, but that is what the method should do. |
|
|
"chainsaies" |
bob.capitalize("butterfly"); |
|
|
"Butterflies" |
bob.capitalize("CS139"); |
|
|
"CS139" |
bob.makeSmall("CS139"); |
|
|
"cS139" |
bob.makeSmall("Harris"); |
|
|
"harris" |
Output
The only output you must worry about in this PA is
the output of the getInteger(), getDouble(), getToken() and getLine() methods. For these methods,
the output should be of the form:
prompt
message where the prompt message is the value passed to the
method.
Following the read from the keyboard, you should
output "\n" (a new line).
All other output will be done for you in main. (Cheers all around!)
See the sample output document for what the JGrasp session might look like when running the tester program.
SampleOutput.txt
Error Handling
You do not need to be concerned wtih Error Handling in this PA.
Additional Program Requirements
- You must use the method headers as provided in the Toolkit.java
file.
- Your program must conform to
standard Java programming standards and the additional standards for
this class. See the Style Guide for your class.
- You must create a program called MyTester
which will be test each method with at least one value (you will simply need to call the getInteger, etc methods and echo their output, but for the others you should use and print sample data similar to what we do in the ToolkitTester.java program
that we provide. You should display the results of those tests (using a
print statement).
Honor Code
This work must conform to the
JMU Honor Code and the specific requirements
of this class. NO help may be provided by any student to another
student.
Authorized help is limited to your textbook, the TAs for any
CS139
or CS239 section, and the professor for your section. See collaboration
policy.
Grading
- Your program will be
evaluated both by its correctness and conformance to the required Style
elements.
- You will achieve a grade of
65 pointsfor a program that runs correctly
and produces exactly the required output in the required format on time.
- You should provide a "main" program called MyTester which
contains at least one call to each method. You will not submit
this file, but will print it as a text document and attach it to your
pdf report. I will not evaluate MyTester for conformance to the Style Guide as it is
a tester for your use only. The examples in MyTester should be different than the examples in the ToolkitTester.java program.(10 points)
- After you have successfully submitted, you will fill out a reflection document as you did for PA1 (5 points). Reflection.doc
- The remainder (20 points)
will be
based on your conformance to the Style Guide and other requirements of the
assignment. Review the Style
Guide before submitting your
program and the grade sheet which is produced by the submit system.
- All grades will be based on
100 points.
- You may submit any number of
times. The only one I will count is the one that corresponds to the
hardcopy report that you turn in.
- The hardcopy that you turn
in will be the formatted version that
I will check. Make sure it has no line wraps or other spacing
issues.
- Successfully submitted
programs that are late will be graded, then the late penalty is
assessed for each day late according to the following schedule.
For
submissions after:
- Oct. 11 - 5 points
- Oct. 12 - 15 points
- Oct. 13 - 25 points
- Oct. 14 at 5pm - 35 points
- Oct. 16 - 45 points
- Oct 17 - 100 points
HINTS
- Begin early.
Students run into trouble by waiting too long to start the
program.
- Write and test one method at a time. Get it working well
(using your MyTester), then move on to the
next method.
- Understand the problem at
hand. Make sure that you follow
the requirements precisely. Don't add additional
"flourishes".
You will be downgraded.
- In the body of your main
method, outline your steps with comment lines for each part of the
project.
- If you wish to use additional methods to break up your code, feel
free to do so.