Comments
File Count.java contains a Java program that
counts from 1 to 5 in English, French, and Spanish.
Save this file to your directory and compile and run it to see what it
does. This exercise is primarily about Java comments. There are two types: first, a "//" means everything including and after the // is treated as a comment by the compiler. Second, a "/*" pairs with the next subsequent "*/" (sort of like parentheses) and everything including and between that pair is treated as a comment. This supports multi-line comments.
You will be submitting to the dropbox for this lab a modified copy of Count.java. As well, your lab document should contain your answers to the starred questions below.
Okay, with
Count.java working, modify
the code
as
follows:
- Use // style comments to add a comment header at the
top of the file that includes the
name of the program, your name, and a brief description of what the
program does, neatly formatted. Include a delimiter line (e.g.,
all stars) at the
beginning and end of the header.
- Add a comment before each println that indicates what language
the next line is in. Experiment with leaving a blank line before each
of these comment lines (in the program itself, not the output).
Is the program easier to read with or without
these blank lines?
- *Remove one of the slashes from one of your comment lines and
recompile the program, so one of the comments starts with a single /.
What error do you get? Record the error message in your lab document. Replace the slash in Count.java
- *Try putting a comment within a comment, so that a // appears
after the initial // on a comment line. Does this cause problems?
To submit:
Submit your Count.java satisfying remarks #1-2 above. The "Comments" section of your lab document should specify your answers to 3 and 4.