Spring2016.CSCI230Homework1 History

Hide minor edits - Show changes to output

Changed line 74 from:
3
to:
2
Changed line 2 from:
'''Due Date''': Τηθρσδαυ, Jan. 21, 2016\\
to:
'''Due Date''': Thursday, Jan. 21, 2016\\
Changed line 2 from:
'''Due Date''': Tuesday, Jan. 19, 2016\\
to:
'''Due Date''': Τηθρσδαυ, Jan. 21, 2016\\
Added lines 111-112:

'''NOTE:''' You may use [[https://en.wikipedia.org/wiki/Javadoc | Javadoc]] formatting, if you prefer. If so, do it consistently.
Added lines 31-34:
!!Note

'''You must use the above method specifications exactly.''' If you deviate from them, our test code will not work, and you may receive a zero for those methods.
Changed lines 49-51 from:
!!Note

'''You must use the above method specifications exactly.''' If you deviate from them, our test code will not work, and you may receive a zero for those methods.
to:
!!! I/O Sample 1

For example, given this input:

(:source lang=Python tabwidth=3 -trim :)
1
5 2 3 1 0 -15
1
0
(:sourcend:)

the output of your program should be:

(:source lang=Python tabwidth=3 -trim :)
true
(:sourcend:)

!!! I/O Sample 2

For example, given this input:

(:source lang=Python tabwidth=3 -trim :)
1
5 2 3 1 0 -15
1
3
(:sourcend:)

the output of your program should be:

(:source lang=Python tabwidth=3 -trim :)
true
(:sourcend:)

!!! I/O Sample 3

For example, given this input:

(:source lang=Python tabwidth=3 -trim :)
1
5 2 3 1 0 -15
1
4
(:sourcend:)

the output of your program should be:

(:source lang=Python tabwidth=3 -trim :)
false
(:sourcend:)

and so on.
Changed line 27 from:
# @@int countItem(int[] list, int item)@@, which returns a count of how many times @@item@@ appears in @@list@@.
to:
# @@int countItem(int[] list, int item, int startIndex)@@, which returns a count of how many times @@item@@ appears in @@list@@ (inclusive) starting from @@startIndex@@.
Changed lines 21-22 from:
# @@boolean isMember(int item, int[] list, int startIndex)@@, which returns @@true@@ if @@item@@ is in @@list@@ starting at @@startIndex@@, @@false@@ otherwise.
to:
# @@boolean isMember(int[] list, int item, int startIndex)@@, which returns @@true@@ if @@item@@ is in @@list@@ starting at @@startIndex@@, @@false@@ otherwise.
Changed lines 27-28 from:
# @@int countItem(int item, int[] list)@@, which returns a count of how many times @@item@@ appears in @@list@@.
to:
# @@int countItem(int[] list, int item)@@, which returns a count of how many times @@item@@ appears in @@list@@.
Added lines 30-43:

!!Input

The program should accept several lines of input, as follows:

an @@int@@ (e.g., 1), which specifies which method to run (e.g., the first method above)\\
the number of integers in the list (0 or more), followed by those integers (these should be read into an array by your code)\\
any other parameters required by the method (one per line)

You may assume that the input is formatted properly and is valid.

!!Output

The program should output the value returned by the method called. Nothing more.
Added lines 1-63:
'''Assigned Date''': Tuesday, Jan. 12, 2016\\
'''Due Date''': Tuesday, Jan. 19, 2016\\
'''Due Time''': 5 mins before beginning of class

Last modified on {$LastModified} (see [[http://www.cs.cofc.edu/~manaris/index.php/Spring2016.CSCI230Homework1?action=diff&source=n&minor=n | updates]])

!!Purpose

This assignment focuses on:

* deriving recursive solutions
* implementing recursion in Java
* Java programming style and documentation

This is a '''solo''' assignment. '''You may discuss the assignment only with the TA or the instructor.'''

!!Assignment

Create a Java program, @@Recursion.java@@, which contains the following recursive methods:

# @@boolean isMember(int item, int[] list, int startIndex)@@, which returns @@true@@ if @@item@@ is in @@list@@ starting at @@startIndex@@, @@false@@ otherwise.

# @@int numberItems(int[] list, int startIndex)@@, which returns the number of items (inclusive) starting from @@startIndex@@ all the way to the end.

# @@int numberItemsReverse(int[] list, int startIndex)@@, which returns the number of items (inclusive) starting from @@startIndex@@ all the way to the beginning.

# @@int countItem(int item, int[] list)@@, which returns a count of how many times @@item@@ appears in @@list@@.

# @@int[] reverseList(int[] list)@@, which returns a new array containing the @@list@@ items in reverse order. The original @@list@@ should remain unaltered.

!!Note

'''You must use the above method specifications exactly.''' If you deviate from them, our test code will not work, and you may receive a zero for those methods.

!!Documentation

Follow the Golden Rule of Style: "A program should be as easy for a human being to read and understand as it is for a computer to execute." [1]

In general, you should comment any variable, obscure statement, block of code, method, and class you create.

Your comments should express '''why''' something is being done, as opposed to '''how''' the how is shown by the code.

Also see the class's [[http://www.cs.cofc.edu/~manaris/uploads/Java%20Coding%20Standards.pdf | Java coding standards]], for additional information, including top-level documentation.

!!Submissions

Submit via OAKS as follows:

# Create a folder named 'First.Last', where 'First' is your first name, and 'Last' is your last name.

# Place your program inside that folder.

# Compress the folder as a .zip file.

# Upload on OAKS.

!!Grading

Your grade will be based on how well you followed the above instructions, and the depth/quality of your work.

!!Reference

# Cooper, D. and Clancy, M. (1985) "Oh! Pascal", 2nd ed., W.W. Norton & Company, New York, p. 42.