Scores

advertisement
CS100M Project 4 Grading Guide (30th October 2003):
Scores
 c and s stand for correctness and style; see table below.
 Apply bonus for exemplary work or doing additional tasks.
Score
# correctness
errors
# style
errors
0
1
>23
19-23
>15
13-15
2
15-18
3
9-14
4
4-8
5
0-3
10-12
7-9
4-6
0-3
General
(s0a) proper code indentation
(s0b) using named constants, comments, and meaningful variable names
(s0c) line length limited to 70 characters
(s0d) appropriate code headers
Part A (MATLAB)
Encrypt Function
Correctness:
c1a – Correct encrypt function signature (‘function secret = encrypt(sourceStr, key, phaseShift’)
c1b – Correct calculation of key transformation (e.g. when key=6 and phaseShift=0)
– e.g, ‘the quick brown fox’ becomes:
– ‘ZNK WAOIQ HXUCT LUD’ with key=6 and phaseShift=0
c1c – Correct calculation of position shifting (e.g. when key=0 and phaseShift=6)
– e.g ‘the quick brown fox; becomes:
– ‘ICK BROWN FOXTHE QU’ (e.g. when key =0 and phaseShift=6)
c1d – Correct output if input is string of length 1. (function should not crash!)
c1e – Correct output if amount to shift by is greater than the length of the string.
c1f – Correctly checks for alphabetical characters.
Decrypt Function
c1g – Correct function signature (‘function plaintxt = decrypt(secret, key, phaseShift’)
c1h – Correct calculation of key transformation (e.g. when key=6 and phaseShift=0)
c1i – Correct calculation of position shifting (e.g. when key=0 and phaseShift=6)
c1j – Correct output if input is string of length 1. (function should not crash!)
c1k – Correct output if amount to shift by is greater than the length of the string.
c1l – Correctly checks for alphabetical characters.
part1.m and General
c1k – Check that output for example strings to encrypt are correct (if any of the 2 are wrong, lose this pt).
– “640K (RAM) ought to be enough for anybody. - Bill Gates, 1981” becomes:
– N (UDP) RXJKW WR EH HQRXJK IRU DQBERGB. - ELOO JDWHV, 1981640
– “BREAKFAST.COM halted!!!!!...Cereal Port Not Responding. : )” becomes:
– “JVT OHSALK!!!!!...JLYLHS WVYA UVA YLZWVUKPUN. : )IYLHRMHZA.”
c1l – Check that output for example string to decrypt is correct.
- Answer is: ‘IT WAS A COLD WINTER!’
c1m – Check that strfind, strrep, strmatch and strtok are not used in code.
c1n – Calls encrypt and decrypt functions correctly.
c1o – Code displays output.
Style:
s1a –headers comments and appropriate comments included.
s1b – Output for part1.m printed out in nicely formatted fashion.
s1c – Code not redundant.
s1d – Correct filename for part1.m and the 2 functions.
s1e – Does not convert characters to ascii codes.
Bonus (indicated by comment ‘%Bonus implemented – match case’ at start of both functions)
Give 1 bonus point if case of output matches case of input.
Other Bonus:
Give 1 bonus point if code supports negative phase shifting.
Give 1 bonus point if code supports keys greater than 26.
Part B (Java)
Question 1 (Calculator)
Correctness:
c2a – General. Correct program structure (Places code in a static main method, and named the class
‘P4Calculator’ as specified, with matching filename).
c2b – Repetitive syntax errors (e.g, called the System.out.println() method incorrectly throughout, etc).
c2c – Calculates correct value (-7).
c2d – Calculates correct value (0.1111111111111111)
c2e – Calculates correct value (7).
c2f – Calculates correct value (3).
c2g – Calculates correct value (5)
c2h- Calculates correct value (2)
c2i – Calculates correct value (false)
c2j – Calculates correct value (true)
c2k – Calculates correct value (4.586776859504132)
c2l – Calculates correct value (0.8699439610158394)
c2m – Calculates correct value (20.085536923187664)
c2n – Calculates random number between 1 and 6 (Math.random()*5+1)
c2o – Calculates random integer between 1 and 6 ( (int) Math.random()*6+1);
Style:
s2a – Formats output correctly for each part. For instance, as specified in the question, the output for part a
should be “a: -7”.
s2b – No redundant code. E.g, to calculate remainder, should use the ‘%’ operator instead of a loop.
N.B.: Comments not essential for this question.
Question 2 (Fibonacci Series)
Correctness:
c3a – Defined base cases correctly (prints 1 for inputs of 0 and 1).
c3b – Correct calculation for general case (some testcases: Fib(10) = 89, Fib(12) = 233, FIb(15) = 987).
c3c – Prompts user for input correctly using Keyboard.readInt() and imports cs1.Keyboard class correctly.
c3d – Use scalar primitives only as specified in the question.
Style:
s3a – Prints output in a nicely formatted fashion.
s3b – Displays user prompt before reading in input.
s3c – No excessively redundant code.
s3d – Appropriately commented code.
s3e – Correct program structure – Class name should be Fib.java, code should be in static void main
method.
Question 3 (Guess.java)
Correctness:
c4a – Calculates random integer between 1 and 100 inclusive ( (int) Math.random()*100+1)
c4b – Used only scalar primitives and correctly initialized scalar primitives for number_of_guesses and
guess.
c4c – Correct stopping conditions in while loop
c4d – Reads in input from the user correctly using Keyboard.readInt()
c4e – Correctly compares user guess with random number.
c4f – Defined sentinel value for user to quit.
c4g – Increments number_of_guesses if user did not enter sentinel value.
c4h – Prompts user to play again and restarts if user says yes.
Style:
s4a – Comments for the main class and while loop/if statements.
s4b – Displays a prompt to user before asking for input
s4c – Notifies user of sentinel value to use for quitting.
s4d – Nicely formatted printouts in general.
s4e – Code not excessively redundant.
Bonus:
1 bonus point for correct use of DecimalFormat
1 bonus point for correct handling of case where there are 0 low cases.
Question 4 (Java API)
Correctness:
Part a:
c5a – API is ‘Application Programming Interface’
c5b – 2 of following 3 items:
–API is a listing of avaliable classes.
– Instance/static methods and variables for each class are listed.
– Brief desc of functionality of class and methods/variables is included in API.
Part b:
c5e – Math.E
c5f - Math.PI
Part c:
c5g – Correct answer of ‘System.currentTimeMillis()’
Part d:
c5h – Mentions that it trims whitespace from start and end. (missing out either start or end is sufficient to
lose this point)
c5i – Methods that it trims ascii control characters too from start and end.
Part e:
c5j – Mentions that ‘0’ matches all digits, while ‘#’ matches all digits with the exception that 0 is absent.
Style:
s5a – filename is api.txt
s5b – Used line breaks to limit the length of each line.
Download