ICS 111, Introduction to Computer Science
Lab 3 - String Methods - June 3
Instructions:
Note: The login / password that you signed up for is for using the computers in the lab. 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.
To receive credit for this lab assignment, you must be finished by
Tuesday, June 3, 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. Login to UNIX (Secure Shell in Windows)
- If you're at home, a good program to use to connect to UNIX
is Putty (click here to download).
The putty program is executable and doesn't need to be installed.
- Host name is: uhunix2.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 a Java file using Pico (Getting Started with Pico)
3. Edit the file in Pico (Getting Started with Pico), then compile and run the program.
Do the following:
- create the String sAbc = "abcdefghijklmnopqrstuvwxyz ,;-" (note: everything inside the quotes is part of the String)
- use the above String to make the sentence "JAVA is cool". This can be accomplished by using the methods charAt(), toUpperCase(), and concat(). Note the space in the string above, after the 'z'- you can use this character to make spaces in your sentence.
- Some examples:
- sAbc.charAt(9) will return 'j'
- and sAbc.charAt(0) will return 'a'.
- To store the character 'J' into a String, you could do the following two lines of code:
- String output = "" + sAbc.charAt(0); (Note: you cannot simply store a character into a String, since characters and Strings are not the same, so you need to 'add' the character on to the end of the empty String)
- output = output.toUpperCase(); (Note: the .toUpperCase() method capitalizes the entire String- so if your String contains 'I love Java' your new String will be 'I LOVE JAVA')
- If you had two Strings to concat:
- String a = "part1";
- String b = "part2";
- String output = a.concat(b); (output = part1part2)
- If you had three Strings to concat:
- String a = "part1";
- String b = "part2";
- String c = "part3";
- String output = a.concat(b.concat(c)); (You could also do the following: String output = a.concat(b).concat(c);)
- The above set of statements would store 'part1part2part3' into the String called output.
- Before you submit your code, make sure that your code is formatted cleanly. Every time you open a new {, you should indent everything one tab (or 5 spaces) underneath it. For example:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
4. Get into Pine (Getting Started with Pine, PDF)
5. Attach the file (.java) to an e-mail (See pages 11-12 in Getting Started with Pine, PDF)
6. Send the e-mail / file to the ics111-lab@hawaii.edu account.
7. 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
7. Once I (TA) get the e-mail in my account AND I can verify it on the web, you will receive your lab participation point. For grading policies on your lab, click here...
* Some may argue that it is easier to do this from WebMail. If you e-mail your homework from webmail, it means that you're not positive that it runs / works properly in UNIX. This could result in point deduction if your stuff doesn't work properly.