CISC 1115
Introduction to Programming Using Java
Labs Home Page

List of Labs

Lab # Description
1 Introductory lab
2 Floating point, Weighted Averages
3 Conditionals
4 Methods
5 Files
6 Logical Operators
7 Techniques I
9 Loops
10 Techniques II
11 Arrays
12 Techniques III
14 Techniques IV

About the Labs

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 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:

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

Submitting the Lab Exercises to Codelab

Once you're satisfied that your program 'works', you should submit it to CodeLab:

"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:

About Grading ← Important!

About Deadlines and 'Freeze' Dates ← Important!

Labs will be associated with lectures … 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

Exercises are marked for Approval for several reasons:

A Note on the Output Displayed by CodeLab

How CodeLab Provides Feedback on Console and File Output

Note: The following display has changed a bit, but the essence is still the same.

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.

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