Assignment FAQ Development Guide Code Checklist |
You should use this guide to help you to complete your assignment. You should follow it step by step, resolving errors before going on to the next step. Once you can follow this guide without errors, you should come up with more test cases to check your code. Being able to follow this development guide does not guarantee full credit.
[*DEBUG: The length of the string displayed is 25]
Please enter a string: Hello World!
[*DEBUG: The length of the string just entered is 12]
[*DEBUG: The length of the string displayed is 16]
[*DEBUG: The length of the string displayed is 12]
The string is: Hello World!
[*DEBUG: The length of the string displayed is 15]
Its length is 12
OVERLOOK REMAINING OUTPUT
Notice the extra output printed to the terminal when you run with the -x option as compared with running the executable without the -x. These are debug messages that give the programmer extra information while a program is running to help them diagnose any problems with the program's code. For this assignment, the extra output indicates how many characters were printed in writeline, and how many characters were read in getaline. From now on in CSE 12, all assignments will include the command line option -x, which will give useful debugging information. In this assignment, -x will help you determine if your program is printing or reading in the correct number of characters.
We recommend writing the debug output early on so that you can use the information for debugging.
In hw2.java, you will add debug output to methods writeline and getaline. You should make use of the pre-written debug messages located at the top of both files. Remember that fprintf to System.err.print are used to print debug messages. Note: there is no "correct" debug message order, as output will vary based on implementation For example, the 0x in hexout can be printed using fputc calls or a call to writeline. (Printing the 0x with writeline would cause a debug message to appear, while printing with fputc would not).
$ jdb hw2
This runs your program and creates a VM that we can connect to using jdb.
$ \jdb -attach 80[xx]
...
main[1] stop in hw2.getaline
...
main[1] run
The string is: abc
Its length is 3
$ jdb hw2
Please enter a string: awesome
The string is: awes
Its length is
OVERLOOK REMAINING OUTPUT
$ jdb hw2 -x
$ \jdb -attach 80[xx]
...
main[1] stop in hw2.writeline
...
main[1] run
...
main[1] cont
$ jdb hw2 -x
Please enter a string:
[*DEBUG: The length of the string displayed is 25]
Hola Mundo!
[*DEBUG: The length of the string just entered is 4]
The string is:
[*DEBUG: The length of the string displayed is 16]
Hola
[*DEBUG: The length of the string displayed is 4]
Its length is
[*DEBUG: The length of the string displayed is 15]
4
$ \jdb -attach 80[xx]
main[1] stop in hw2.decin
...
main[1] run
...
main[1] next
DO 'next' AS MANY TIMES AS NEEDED
$ ./driver
Please enter a string: Hola Mundo!
The string is: Hola
Its length is 4
Please enter a decimal number: 9876543211234567890
digit 0 caused overflow!!!
Please reenter number: 123cse
digit c out of range!!!
Please reenter number: 4
Please enter a decimal base: 10
OVERLOOK REMAINING OUTPUT
$ make new
$ ./driver
Please enter a string: Hello world!
The string is: Hello world!
Its length is 12
Please enter a decimal number: 123
Please enter a decimal base: 10
Number entered in base 10 is: 123
And is decimal is: 123
And in hexidecimal is: 0x000000000000007B
Number entered multiplied by 8 is: 984
And in hexidecimal is: 0x00000000000003D8
OVERLOOK REMAINING OUTPUT
Note that, in order for your homework to be collected correctly, you must name your file hw2.java and the file must be located in a folder called hw2 in your home directory.
Assignment FAQ Development Guide Code Checklist |