![]() |
Computer Science Department |
Objectives: |
This lab will give students a chance to practice writing method bodies. |
Background: |
Methods
allow us to break a problem up into smaller units. Each of these
methods will do a single task. In some cases the task is to calculate
and print a value; in other cases, its task is to do a calculation and
return a new value. |
New Terms: |
|
Materials: |
All of these methods should be written from scratch. All should be stored in a .java file named Methods.java. You may download the driver to use to submit your program (Driver.java). All programs should be submitted to the Linux submit system. The Driver uses a command line argument to determine which method it is testing. |
Acknowledgment | From an original lab by Nancy Harris |
Download the Driver.java and the Methods.java files to your programming environment.
Methods.java is a set of stubs for each of the methods. A stub is simply the
header and if necessary a return statement. These stubs are designed to let you
compile the class and add code in as you develope it. The Driver includes all of
the code needed to "exercise" each of the methods. You may create and test
them one at a time. Driver takes in an argument corresponding to the number
of the method you are testing (1 is reformName for example). You can test one
method by typing the number in as an argument. The instructor will demo the command line argument in JGrasp.
You may tackle problems in any order that you choose. You will likely see a variant of one of these problems on the upcoming exam.
Thoroughly test your problem.
When you are convinced that you have the correct solution, submit to stu with the Driver.java program. There will be one submit for each problem.
You get a grade of 65 for one correctly solved problem, 75 for 2, 85 for 3 and 100 for correctly solving four problems.
You do not need to print anything nor do you need to upload anything to Blackboard. Your grade will be based on the number of correctly solved problems in submit.
Many of these problems have come from the Programming Challenges section of chapter 2 in your book.
Updated 09/29/10 (nlh)