Programming Assignment 1
(Due by 9 pm, Friday, September 5, 2008)
This project is to be completed individually - all work submitted
must be only yours.
Goals for this project:
Activate your account, join the class discussion group, and remember
how to write Java classes using conditional statements and loops, get input
from the keyboard with the Scanner class (plus a couple of methods from
the Math class). You will turn in two programs, AverageTemp.java and
For your first assignment, you will do the following:
- Obtain a CS lab account by Monday, September 3rd: See instructions on syllabus. Ideally you should do this soon, as it
takes at least one full day (and sometimes longer) for your account to
be activated. You can either do this from your own machine, or there is
a machine in PAI 5.38 that is set
up to allow students to request account activation. You must remember
the account name and password you choose - they will not be emailed to
you. You will use this account to turn in your files, even if you do
not work in the lab.
- Join the class
yahoo group. You should check messages on this group regularly - I
will assume you have read any announcements that are posted on it. Ask
and answer questions related to course material here. Never post
solutions to class exercises. You might also want to use the class
yahoo group to find a study group.
- If you plan on working from home during the semester, download
Java onto your computer using these
instructions. You will probably want to use an IDE when working on
programming assignments; I recommend that you use blueJ. Download
and install blueJ on your computer.
Enter air temperatures or
a number less than 0 to quit:
- Successfully login to a computer in the Elements Lab.
- Start BlueJ: On the lab PC, click Start button, then select
Programs, and click on BlueJ. If you do not find it, do not hesitate to
ask the TA or proctor.
- Create a Project: Go to Project -> New Project. In the File
Name field, type Lab1
for the project name and click on
the Create button. The Project window will open and you will see
buttons on the left that say "NewClass", "Compile", etc. On the right,
you will see a graphical window that contains a file object icon.
- Create a Class: Click on the New Class button. A New Class
dialog box will open. Type "AverageTemp" in the Class Name field. Leave
the class option selected and click OK. In the graphical window, you
should now see a new object called AverageTemp. Double-click the
object to open it. This is going to be your AverageTemp.java
file. You have a template to work with, most of which you will modify
for your purpose.
- Write your AverageTemp program (a class with a main method only)
that determines the lowest, average(mean) and highest temperature in a
set of temperature readings that are all positive or zero (we're in
Texas, after all). A negative input terminates the input, and the
lowest, average and highest temperatures are displayed. Round the
average to the nearest integer. Here is a sample run, with the user's
input in red:
High Temp: 60
Low Temp: 30
Play the guessing game... guess my random number from 1 to 100
Pick a number from 1 to 100: 50
50 is too high.
Guess a number from 1 to 100: 25
25 is right!
You needed 2 guesses.
- Store your program in file Guess.java, and submit this file
the appropriate header) using the turnin program.
- Close BlueJ: Make a backup of your AverageTemp.java and
Guess.java files on a
memory stick and then logout of the computer. Always save your
BEFORE logging out - once logged out all your information is lost
saved elsewhere. You can save your file on a memory stick, or by
emailing the file to yourself, or by using the turnin program. But
don't log out before you save your program.