ICS 111, Introduction to Computer Science
Lab 6 -
Note: The login / password that you signed up for is for using the computers in the lab this semester. Please write down your username and password and keep it in a safe place, since you will need this for every lab this semester.. This user name / password is only for gaining access to the lab computers, and has nothing to do with logging into UH UNIX.
Also, be careful and make sure that you logout from the computers when you leave the lab or other persons may see your stuff or use your account to do "bad" things.
Instructions:
To receive credit for this lab assignment, you must be finished by
Thursday, September 16, at 11:59 p.m. After this time you will not receive any credit. Future lab assignments will be due by 11:59 p.m. on the day of the lab assignment.1. Log in to UH UNIX (Secure Shell in Windows)
- If you are in the lab, go to the Start Menu, then Programs,
and look for 'SSH Secure Shell Client'. If you're at home, a good program to use to connect to
UH UNIX
is Putty (click here to download).
The putty program is an executable and doesn't need to be installed.
- Host name is: uhunix.its.hawaii.edu
- Your user name is the first part of your UH e-mail address.
If your UH email address is 'frank@hawaii.edu', your user name would be 'frank'.
Your password is the same as your e-mail password.
2. Create and edit a file in Pico (Getting Started with Pico), named LabX.java (substitute the X for the lab number- e.g. Lab5.java)
Do the following:
- Read 3 numbers (grades) from the user. Do not use the cs1.Keyboard class like the author. Use the InputStreamReader and BufferedReader that Blanca taught in class.
- Parse the input Strings for numbers. Keyboard input, even numbers, is brought in by the BufferedReader as a String. You need to use the parseInt or parseDouble method to pull the integer number from the String.
- Calculate the average of the three grades.
- At this point there is no validation so some wacky stuff may happen (with bad user input). Later on in the course you will be asked to modify it to include if-statements for the number range, and asked to implement a try / catch statement for catching any exceptions thrown by the parse methods.
- Throughout your program, print user-friendly messages asking for and acknowledging the user input. A good way to acknowledge the user input is to print a message after the user enters a number, and tell them the number they entered.
- After the three numbers are entered, parsed, and averaged, print a user-friendly message telling the user what the average of the three grades was.
- Create comments throughout the program to reflect what the program is doing. For guidelines on formatting your code and for comments, see the Java Coding Standard .
- Before you submit your code, make sure that your code is formatted cleanly. Refer to the Java Coding Standard and make sure your code adheres to its rules. For example, every time you open a new {, you should indent everything underneath it two spaces like the following:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}You must also follow all of the commenting guidelines. Be sure to visit the link and check that your code follows all of the guidelines. Failure to do so will result in a deduction of points.
* Your program must compile without any errors, and must run properly to receive credit for this lab.
Notes: Don't forget that Java and UNIX are case sensitive. Therefore 'helloworld.java' isn't the same as 'HelloWorld.java'. Also, remember that your class name must match your file name. If your class name is 'Frank' then your filename would be 'Frank.java'. You would compile by typing 'javac Frank.java' and you would run the program by typing 'java Frank'.
* Your program must compile without any errors, and must run properly to receive credit for this lab.
3. Get into Pine (Getting Started with Pine, PDF) and attach the Java (.java) file to an e-mail (See pages 11-12 in Getting Started with Pine, PDF).
- Send the file to ics111-lab@hawaii.edu account.
- control <J>, then control <T> allows you to browse and pick the file that you wish to attach. Only submit the .java file. Do not submit the .class file.
- Your e-mail should have the following subject: lab X / lastname (lab X should be substituted with the lab number, and lastname should be substituted for your lastname... e.g. Lab 5 / Sharritt). Not following this standard will result in a deduction of points.
* Some may argue that it is easier to do this from WebMail or other e-mail programs. If you e-mail your lab / homework from anything besides Pine, it means that you're not positive that it runs / works properly in UNIX. Other email programs often add end-of-line characters. This could result in large point deductions if your program doesn't work properly.
4. Check the webpage to make sure that the e-mail arrived. Note that this will be sent to the ICS 111 lab address (ics111-lab@hawaii.edu). This one is different from the ics111-homework@hawaii.edu. There are two different ones so we can have homework assignments and lab assignments separate.
Here are the URLs:
http://www2.hawaii.edu/~tp_200/bmf/ics111-homework.html
http://www2.hawaii.edu/~tp_200/bmf/ics111-lab.html
5. Once we (TAs) get the e-mail in our account AND we can verify it on the web, we will grade your lab. For grading policies on your lab, click here...
Link to the Java API - to look up any methods of any class you would like to use.
Link to the Java Coding Standard - to look up Java code formatting rules.