Trial Lab
Trial Lab (CS1101 AY2009/10 Semester 1)
This lab assignment is not graded.
Date of release: 15 August 2009, Saturday, 7:00hr.
Soft submission deadline: 24 August 2009, Monday, 23:59hr.
School of Computing, National University of Singapore
0 Introduction
This trial lab is for you to test out the CourseMarker
system
and to iron out any problem before we start the
first take-home lab assignment in week 3. This trial lab is
not graded, but you must attempt this, otherwise you will
not be allowed to submit your subsequent lab assignments.
For more information on CourseMarker (and how to install it on your
own computer if you wish), please refer to the
CourseMarker website and the PowerPoint file
on the CS1101 Labs page.
If you have problem with the installation, you may
post your queries in the IVLE discussion forum,
email cmarker@comp.nus.edu.sg,
or approach the Technical Services counter
at the ground floor of COM1.
You may assume that all input data are correct.
In general, you should use Scanner class on System.in for
input and System.out for output in your programs,
unless otherwise stated.
Test your programs thoroughly with your own input data before you
submit to CourseMarker. Do not use CourseMarker as a debugging tool.
For this trial lab, the number of submissions is set to 99.
1 Exercise 1: Volume of a Cube
1.1 Learning objectives
- Using CourseMarker.
- Run through the edit-compile-run cycle of program development.
- Using the programming environment.
- Detection and correction of errors in program.
1.2 Task
Write a program that reads three positive integers representing
the length, width and height of a cube, and computes the volume
of the cube.
You may assume that the volume of the cube does not exceed the
maximum value representable in the int data type.
(What is that maximum value?)
1.3 Sample run
Sample run using interactive input (user's input shown in
blue; required output shown in
bold purple). Note that the first two
lines (in green) below
are commands issued to compile and run your Java program if you are
using in-line commands, for example, on UNIX. If you are not, you
may ignore them.
$ javac Volume.java
$ java Volume
Enter length: 12
Enter width : 3
Enter height: 10
Volume = 360
1.4 Submission
Submit your program through CourseMarker.
1.5 Important notes
- It may seem that this lab requires knowledge
which is not yet covered. Do not fret. You are given
a skeleton program which is almost complete. You just need
to correct two statements in the program.
- The skeleton program is provided here:
Volume.java.
When you click on Setup in CourseMarker, this skeleton program
will be loaded for you. (You are reminded to click Setup
only once for each exercise, as your program will be replaced
by the skeleton program each time you click Setup.)
- CourseMarker awards mark for correctness ONLY if your output
adheres to the given format. Hence,
do not add any other characters (such as blanks) that are not asked
for in your output, or change the spelling in your output.
The following outputs will all be graded as incorrect for
the above example:
- volume = 360
(reason: "Volume" misspelt as "volume")
- Volume=360
(reason: spaces around = sign missing)
- Volume = 360
(reason: additional spaces before "Volume")
- Volume = 360
(reason: too many spaces around = sign)
- Volume = 360.
(reason: additional dot at end of line)
- Note that your last output statement in your program should be
System.out.println instead of System.out.print.
This is a requirement for CourseMarker.
- Note that your program will be tested with a number of test data
sets, which are DIFFERENT from the given example.
- This trial lab is for your familiarisation with CourseMarker.
Marks awarded for this lab will not be recorded. However,
you must attempt this trial lab, as we will record your
attempt.
1.6 Exploration
You may want to explore more since you are new in programming. You can
try the following suggestions just for your own practice (do not submit to
CourseMarker!). The suggestions are independent of one another. You
may try other changes on your own. You may discuss your observation with
your discussion leader.
- You use int type for the volume in this program.
You will learn in class that int type uses 32 bits. Can you try some
input values such that the program 'bombs' (terminates with error)
because the computed volume is larger than what int type can hold?
- Use the double type instead of int type in your program.
- Compute the perimeter of the cube.
- Compute the surface area of the cube.
2 Deadline
There is no deadline for this trial lab, but you are urged to
submit before 24 August 2009, Monday, 23:59hr.
Aaron Tan
Fri Jun 19 09:37:52 SGT 2009