CISC 1115
Introduction to Programming Using Java
Labs Home Page
List of Labs
About the Labs
- The labs are meant to supplement the corresponding lecture
- The content of the lab will be closely tied to the material covered in the corresponding lecture.
- You are responsible for the lab even if you miss that class.
- Feel free to copy/paste the files included with the lecture as a starting point for your lab.
- You may NOT however cut and paste from any other source, than than your own notes and/or code
- In particular, copying code from another student, and/or website, and/or any other source will result in a 0 for the entire
lab, and will be reported to the college Academic Integrity Committee.
Working on the CodeLab Exercises
The CodeLab exercises are very short (usually a couple of lines) fragments of code that focus on specific topics covered by the corresponding
lecture (think of them as homework questions at the back of a text's section or chapter). They serve to help reinforce the material and also to
prepare you for the larger labs. They are designed to be completed within the CodeLab Workbench (in fact, since they are not full programs, but
rather fragments, they can't be completed in your IDE).
Working on the Labs
- The labs are somewhat larger — typically full program — that employ both the material of the current lecture topics but previous ones as well.
- Each lab has a header consisting of a descriptive title for the lab (e.g. 'An Empty Application') followed by the class/program/app name to be used (e.g.
EmptyApp
)
in parens.
- You should develop your lab solutions using your IDE (e.g. IntelliJ):
- Once you've got the lab 'working', you should submit it to CodeLab for checking and possible approval.
- 'Working' means:
- Compiles without compilation errors
- Executes to completion (i.e., no crashes, or other runtime error / exceptions)
- The answers are correct — you should be determining this by:
- 'eyeballing' your output (i.e., looking at it and seeing if the answers are correct.
- In addition, the description of each exercise on the Lab page will often contain one or more test runs which
show the prompts, inputs, and corresponding correct output for the exercise.
- The input is in bold — to distinguish it from what your program prints (pronpts
and output). When you rn your program, you will not be seeing the input in bold.
- There's not much point in submitting it to CodeLab before that.
- The labs are collaborative in the sense that you should feel free to discuss them with other people in the class.
- You should also feel free to look at other's code, but not copy it.
The Output Displayed for the Exercises
Exercises will often be accompanied by the details of one or more test runs. The purpose of these are to:
- Give you some sense of what the program does and what's it's execution looks like.
- Provide information so your program can be successfully submitted to CodeLab. For these lab exercises, CodeLab compares your program's
output with the 'correct' output expected for the exercises.
- It is therefore imperative that the text of your program's prompts and output exactly match that expected by CodeLab
- In order for you to be able to do this, you need to know:
- The expected order of user input
- For example, is the last name entered followed by the first name? or vice versa?
- The exact text of the prompts
- For example, is the expected prompt
Enter a number:
, or Please type in a #
?
- The exact text of the output produced
- For example, is the expected output
Gerald Weiss has an average of 80
or "Weiss, Gerald: 80?
- The test run provides you with all this information.
- In the "Sample Test Runs', user input is in bold to distinguish it from the text output by your program (prompts and output)
- When you are running your program, your user input will not appear in bold.
What the 'Sample Test Runs Aren't!
The Sample Test Runs presented as part of an exercise's instructions are examples of possible data that could be inout to the program … they are not the only
possible values. In general, you cannot code your program to expect or process only those values. (Doing so is a standard newbie mistake.)
Motivation for Each Lab Exercise
- At the end of each lab is a small section explaining the purpose or goal of the lab; i.e., what you hopefully will gain
from completing the exercise.
- It may be simply practice of a new feature or technique, or some challenging problem to make you think, or a new technique
Submitting the Lab Exercises to Codelab
Once you're satisfied that your program 'works', you should submit it to CodeLab:
- Open the course, and go to the corresponding lab under the
Labs
topic.
- Paste your solution (from IntelliJ) into the submission box
- What happens if CodeLab complains about you failing test cases:
- Not every test case used by CodeLab will be presented on the Lab page.
- It may very well be that your code produces correct output for the test cases you see on the page, but fail other test cases
used by CodeLab
- This will be particularly likely if you code toward the test, i.e., you write your solution based on
the test cases you see (as opposed to coding a general solution based on the problem description).
- One or more of the lab exercises in a Lab may be marked for 'Approval', which means that even once it passes CodeLab's tests, it will remain
in a pending state until I look at your submission (for style, comments,etc).
"It 'Works' in IntelliJ, but Not in CodeLab!"
This is a standard newbie complaint … you run your code in IntelliJ and it seems to 'work', but then CodeLab rejects it.
What you mean by it 'working' in IntelliJ is nothing more than no compilation errors appearing (those red lines
indicating something wrong with your code), and when you actually run it you get some output that appears correct. However, there are two
potential problems with that result:
- What looks like correct output might not be; for example, some of you output might not be spelled correctly, or some value out of the many
you are printing may be incorrect. This is where the test-case table in the Results tab comes in; it shows you any discrepancies between YOUR output
and the correct one expected by CodeLab (don't forget, in general, your output must match the expected EXACTLY).
- It may be that your output IS correct, however, that is for only one test case. For example if you are asked to write a program that multiples two
numbers and you mistakenly add the two numbers, and you test it on 2 and 2, your program will produce what looks like the correct answer … 4.
However, when CodeLab tests it on 3 and 2, your program will not produce a correct answer. (This is a trivial case, but the basic idea.)
About Grading ← Important!
- Exercises are either correct or not.
- If they are marked as correct, you get full credit for the exercise; there is no numeric grade
- If the exercise is not marked as correct, you essentially get no credit for it, any partial credit is solely at my discretion
- partial credit assigns a percentage of a fully credited exercise
- 'not correct' includes:
- never attempted
- attempted but did not pass CodeLab
- this includes failing at compilation, failing all test cases, failing some test cases, failing due to a runtime error
- an approval that passed CodeLab but was rejected by me
- In the event of incorrect, I may assign partial credit depending on how close to a correct answer you came
- The essential idea is that in a working environment a partially correct program would never be released to the general population
- You should not get into the habit of thinking that a program 'almost' works
About Deadlines and 'Freeze' Dates ← Important!
Labs will be associated with lectures …
- when a lecture first appears on the calendar, the corresponding lab will be posted in the Class Calendar.
- once the lecture has been completed, the lab will be assigned a deadline; typically one to two weeks from that date.
- submissions beyond the due date will be marked as late.
- one week beyond the due date, the exercise will be frozen
- submissions past the frozen date will not be entered in the roster — however, you can still work on them for your own benefit
Again, all these dates will be posted in the Calendar
Only labs submitted to CodeLab are considered; there is no other mechanism for submitting your work.
'Approval' Exercises
- Some exercises may be labelled as requiring 'Approval' both on the lab page as well as so marked in Codelab.
- Approval exercises require my approval (in addition to the usual Codelab 'correctness' checking).
- You cannot submit the exercise for approval until it has passed Codelab's tests.
- Once you have passed CodeLab's checking, the exercise status in the Table of Contents changes to a blue check:
- At that point you can immediately, you submit the exercise for approval using the corresponding button
in the upper right of the Results tab in the workspace area (next to the 'Ask Your Teacher' button):
- Before submitting for approval, make sure your code is properly indented, and any required documentation (comments) are
included
- CodeLab accepting the exercise does NOT automatically submit it for approval; you must do that yourself.
- I will then accept or reject the exercise; in the latter case, I will specify what I found unacceptable.
- Once you have passed the CodeLab check, the deadline is no longer relevant; i.e., even if I reject the exercise and ask for resubmission, you will
not be penalized.
Exercises are marked for Approval for several reasons:
- I want to check your style / indentation / documentation
- This is especially true at the beginning of the course
- The exercise involves something that can't be checked by Codelab
- For example, if I ask for a specific sort algorithm; Codelab can only check that the arrays has been sorted, but not how
A Note on the Output Displayed by CodeLab
- If your submission fails CodeLabs tests, you will be presented with your output as well as the expected output
- What you will see is only the text printed by your program (and the corresponding output of
a 'correct' solution).
- In particular, you will NOT see the user input, as it was supplied by the user, and not printed by your program.
- As an example. Given the following program that prompts the user for their last and first names and prints a greeting of the form
Hello first name last name!!
import java.util.*;
public class Hello {
public static void main(String [] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter last name: "); // prompt
String lastName = scanner.next();
System.out.print("Enter first name: "); // prompt
String firstName = scanner.next();
System.out.println("Hello " + firstName + " " + lastName + "!!"); // output
}
}
- Here is what the execution would look like if you ran the program (notice — no bold):
Enter last name: Weiss
Enter first name: Gerald
Hello Gerald Weiss!!
- Here is what how the execution is displayed on the lab page (as well as in the CodeLab instructions for the exercise (notice the bold):
Enter last name: Weiss
Enter first name: Gerald
Hello Gerald Weiss!!
- In both of the above cases, you see the user input entered from the keyboard. But the actual output produced by the program
(i.e., the output produced from the
print
or println
messages sent to System.out
) is actually:
Enter last name: Enter first name: Hello Gerald Weiss!!
- Notice the absence of any of the user input (that was not printed by the program's
print
message)
- This is what CodeLab will display as your program's output (it will also display similar user-inputless
output for the expected output).
- This takes a bit getting used to, but since both your output and the expected output are displiayed this way
it should not be too difficult for you to find the discrepancies.
How CodeLab Provides Feedback on Console and File Output
Note: The following display has changed a bit, but the essence is still the same.
- If the exercise involves writing output to standard output or a file, errors made in that output will result in the following feedback:
- Scroll down to the bottom of the page (below the "Your Submission" window — or use the arrow to collapse that window),
where you will find the Test Case Table where at least one of the test cases will be incorrect:
- Click the which will bring up the Output Comparason Table:
- The text in
red strikeout (fals
in the above example) highlights incorrect text in your output, i.e., text that should not be
there (or at least not in the location it appears). You need to fix your program so that this is NOT displayed
- The text in green underline (tru
in the above example) displays missing text in your output, i.e., text that should be at the specified
location but is not present in your output. You need to fix your program so that this IS displayed
When You are Stuck, or Things Seem to be Wrong
There will be times where you just can't seem to get the correct solution, or are not sure how to do an exercise. There may be other time where you think
something is wrong with Codelab. Fret not, Codelab has facilities to allow you to notify us of any issues.
Getting Stuck and/or Not Sure How to Proceed
If you are stuck on an exercise; i.e., Codelab has told you your output is wrong, or you are getting a compiler error (or any other error( you do not understand,
you can send me a query asking me to look at your submission. Simply submit your attempted solution, and then click the Ask Your Teacher
button in the upper
right corner of the Results
tab:
You will be prompted for a message to send and I will receive it as well as complete information on your submission.
Even if you are not at the Codelab stage yet — i.e., you are still working on your program in IntelliJ — you can always copy your code from
IntelliJ, paste it into the corresponding exercise in Codelab, submit it and then submit a query.
- Please use this facility for questions about your submissions. Please do not send me questions about your submissions through
email … without my also receiving the information about your submission, I cannot do much to help you.
- I typically look at the queries a couple of times a day … please be patient. If you see me in class or elsewhere, feel free to let me know
you sent a query.
- Often (hopefully), you will figure out the problem (and submit a correct solution) before I get back to you. I can tell this when I read
the query, and will not respond in that case.
Sending a query can also be useful if you think the exercise has a mistake in it; for example something is unclear in the instructions. You can also
raise these questions in class.
Something Seems to be Wrong With CodeLab
You may encounter (hopefully very rarely) something that seems to be wrong with Codelab; for example you can't submit a solution, or an error pops up when you submit something.;
in other words an issue with the system rather than a specific exercise. There is often a Content Support button on the upper right of the window as well (you can see it in the
previous image). Click that and again, you will be prompted for a message.
Of course, you can always contact me via email, and at the worst I would tell you how you could have done it through the system (for the next time). o
Sample Test Runs & A Common Novice Mistake: "Programming to the Example"
Suppose I ask you to write a program that reads in a number and prints it out — something fairly simple that might be appropriate in the first couple of weeks of class.
To illustrate what I want, I provide an example. You mught therefore see instructions such as:
Write a Java application that has the use enter a number at the keyboard and then prints out the number.
Sample Test Run
Enter a numer: 12
The number entered is 12
The Sample Test Run is an example execution whose purpose is to give you a sense of what the program does, as well as to show you the exact form of the output
(don't forget, Codelab is very exacting in checking it's output; often even extra or missing blank spaces will cause it to complain).
Notice that the problem is not asking you to print the number 12, nor that the user is asked to enter the number 12 from the keyboard. Rather, the user is
being asked to enter ANY number and it is THAT number that is to be printed. Your program must therefore be able to work regardless of whether the
user entered 12 (our example data) or ANY other number. For example if the user entered 23, the output should be The number entered is 23
.
(This is the whole point of the use of variables instead of hard-coded values in a program; it allows us to run the same program with different
value; for the moment those values will come from the keyboard, but we will eventually learn to get them from elsewhere as well.)
Again, providing an example (i.e., the Sample Test Run) is meant to illustrate how the program works; it it NOT meant to be a specification of the
program. This distinction is often a source of confusion to beginning (and sometimes, not-so-beginning) students; I have seen this mistake in 3115,
and even — though rarely — in 3130. In the above example, this results in the student simply printing out the number 12
(the code
to read in a number is often omitted, or the student may be sufficiently confused and put code in to read a value, and then ignored the value read in.
This error often does not reveal itself until the program is submitted to Codelab. This is because when the student runs the program in IntelliJ, they are seeing
the output they are expecting (i.e., 12
in our example). However, Codelab checks the program using data other than that presented in the
Sample Test Run (for example, Codelab may run the program using the numbers 23, 41, and 220; i.e., it runs the program several times, each time with a different value).
What often happens in this situation is that the student sees data NOT in the Sample Test Run, and submits a query wondering why they're
seeing strange values … again it's the result of Codelab testing the program on different values