Tuesday, August 31, 2010

Lab 04 - Section 6

Problem 8 on page 172 of the textbook.

Lab04 -- Section 5

Problem 4 -- Page 172

In the end, its really just a matter of what works for you, but for some people using an RSS/feed reader works better than just browsing the web. Below is a video that explains how to use google reader, a very popular feed reader and the one I use.

Lab03 Section 6

`Problem 9 and Problem 11 ( both mandatory ) ... since Problem 9`
```is easy .... :) .... Best !!
```

Monday, August 30, 2010

HW 1: Hide The Message

The ROT 13 cypher is a simple method to hide a message so the casual observer cannot reader. It works by replacing each letter with one that is 13 spots later in the alphabet, so that `a` becomes `n`, `b` becomes `o`, and `z` becomes `m`, because we wrap around.

For this first homework you will implement a program that first asks the user for a number, then for a string, and then prints out the given string but rotated by the number of spots the user requested. You can assume that the string the user types is composed only of lower case letters [a-z]. Here are a couple of sample interactions with the program:

```What offset do you want?1

Enter word to translate:abczyx
bcdazy
-----------
What offset do you want?13

Enter word to translate:hello
uryyb

```

You will implement this homework using typecasting and without using any if-then statements, we have not covered those anyway. You will need to use a for-loop.

It might at first seem that you need to know the values in the basic-latin unicode block, but you don't. All you need to know is that all the lower case letters appear consecutively and in alphabetical order in the table. Also note that if you need to know the unicode number of any character, say 'a', you can simply write a simple program with theh line `System.out.println((int)'a');` If you are interested, the wikipedia unicode page tells more than anyone wants to know about Unicode.

You need to either upload your homework to our dropbox or email it to your TA by Tuesday, September 7 @9am.

Update Sep. 2: I messed up, again. I thought that Chapter 3 covered for-loops, but they are in Chapter 4 instead. So, you can read ahead on chapter 4 or just use the code below in your homework:

```  String test = "Hi there!";
//This for loop will print out the numbers from 0 to the length of the
// string in the 'test' variable.
for (int i=0; i < test.length(); i++) {
System.out.println(i);
}
```

That code will loop from 0 to the last position in the string `test`. You will need that to iterate over the letters in the word that the user inputs.

Thursday, August 26, 2010

By now you should have received your grades so far in class: for lab 1 and 2. The grades for the labs have a maximum of 10 points. The emails were sent to your `@email.sc.edu` address. If you did not receive it then send me an email.

Chaper 3 Video

Below is the screencast for Chapter 3 of the textbook. You should watch this lecture and read Chapter 3 before lecture on Thursday, September 2. This chapter introduces `if-else` and `switch` statements. These are the most basic looping constructs and every programming language has them.

For your review, here are the textbook slides for chapter 3.

Lab 2

Lab 02 -- Thursday 08/26/2010 Page 116 -- Problems 4 and 6

Tuesday, August 24, 2010

Style Standandards

All software companies have coding standards, either by decree or by default. These are just basic style rules that everyone must follow so that everyone else can more easily understand their code. Our style rules are based on those used by second graders. Namely
1. You will put your name and email address at the top of every .java file. The more advanced among you can use the @author tag
2. You will properly indent all your code. Control-a Control-i is your friend.
3. You will write comments that describe what your code is meant to do but not comments that merely echo the code. That is: "calculate the marginal tax rate" is a good comment but "increase variable i by 5" is a bad comment.
5. You will ensure that all variable names are spelled correctly. Misspelled variable names are a common source of bugs.
6. You will choose good variable names: i is reserved for simple loops, otherwise the variable should describe its contents, in `camelCasing`, such as `bookTitle` or `netProfit`.
7. Your code will be neat.

Computer majors might want to take a look at our CSCE 240 programming style sheet to learn in more detail about style rules.

Friday, August 20, 2010

Chapter 2 Lecture

Since most of you handled Lab 1 with ease, we will now quickly move on to Chapter 2 in which we actually start to learn to program. You should have read Chapter 2 and watched the screencast below, as well as practiced doing what I do in the video, by Thursday, August 26. Oh, and there will be no lab on Tuesday, Aug. 24.

Below is my screencast for Chapter 2 of the textbook where we cover variables and keyboard and screen I/0. Pay close attention to the different variable types, including `int`, `double`, and `String` (note: proper capitalization is important!)

Also, the slides from the textbook should help you review the material after you have read the book:

Thursday, August 19, 2010

Lab 1

Use your favorite browser to get to the lab instructions. It is a good idea to set a bookmark at http://www.csce145.com as everything for this class will be posted there. If you use a feed reader, subscribe now to both the posts and the comments.

1. The laboratory computer systems run the Microsoft Windows XP operating system. Because it is connected to a server in the College (running Windows Server), you have a login, password, and a "profile" that can follow you around to whatever computer you use within the engineering domain (ENGR). Computer labs are located in Swearingen and 300 South Main (across the street), but our labs will meet in Swearingen 1D15.
3. Note the desktop (i.e., the appearance of the screen). Everyone’s desktop is identical now, but it’s your desktop. Take an inventory of the things on the desktop. You can change it as you wish at your convenience.
4. What you need for CSCE 145 is primarily a web browser, Java, Eclipse. These are all already installed in the lab machines.
5. Double click on the My Computer icon to see what you have. In particular, there are several drives: such as C:, H:, P:, and Z:. We will concentrate on drive H:. Note, if you are going to work from home (you most likely are) then I recommend you use dropbox to backup and synchronize your files across your computers.
6. Open the H: drive by double-clicking on it. Create a new folder on H: called csce145; open the csce145 directory by double-clicking on it; now create a lab01 directory.
7. You are next going to place an icon on the desktop for eclipse. Locate the eclipse folder by clicking on the Start menu, then Programs, CSE Apps, and eclipse. Click on the eclipse icon using the right mouse button. From the menu that appears, choose "send to" and then "Desktop (shortcut)". This will place a shortcut to the eclipse development environment on your desktop for ease of use.
8. Right click the eclipse shortcut that you just made and select properties. Go to Start in and put in the home directory that you made on your H: drive earlier (e.g.: `H:\csce145`)
9. Open eclipse by double-clicking on its icon on the desktop. If the "Welcome" window appears, click on the icon for the "Workbench." Eclipse will request that you "Select a workspace." Choose the default, which should be `H:\csce145\workspace`. If it is not there, type it in and click OK.
10. Use File/New/Project and then choose Java Project and click next. In the window that pops up, choose a project name of lab01 and click next.
11. Finally click finish at the bottom.
12. For the lab this week, you will write a Java program to do simple interaction with a user (you, in this case).
13. Right click on lab01 in the left Package Explorer frame and choose "new class". In the window that pops up, choose a meaningful name for your class (e.g., FirstProgram) and type it in the Name box. In the "which method stubs would you like to create?" section, check the box for `public static void main(String[] args)`. Click the Finish button.
14. A new class file will be created with the basic code you will need for your assignment. Include the following statement at the beginning of the class so that you can use the Scanner class: `import java.util.Scanner;`
15. Then, just below the line with `public static void main(String[] args)` type:
```    System.out.println("Hello out there.");
//two forward slashes means the rest of the line is a comment!!!!

//make a String variable with your    first name -- change this to your first name
String firstName = "Clint";
//make a String variable with your last name -- change this to your last name
String lastName = "Fuchs";

//make a char variable that indicates the grade you want to make in this class
char grade = 'A'; //note single quotes ' around characters

//Finally output all of that information to the screen
System.out.println("My first name is " + firstName + " and my last name is " + lastName +
" and if I study hard, I will make a(n) " + grade + " in CSCE145!");

//prompt the user to input two numbers to add
System.out.println("I will now add two integer values, please enter the two integer values separated by a space: ");

//now we need to create and connect a Scanner object to the keyboard
Scanner keyboard = new Scanner(System.in);

//now we can use the keyboard object to retrieve values from the user
int value1 = keyboard.nextInt();
int value2 = keyboard.nextInt();
int result = value1 + value2;

System.out.println("The result of adding " + value1 + " and " + value2 + " is: " + result);

System.out.println("Goodbye");
```
If you make a typing mistake you can correct it with the backspace or delete key. If you have positioned the cursor somewhere else, then you can use the four arrow keys to get back to the correct line.
16. Use the File/Save to save and compile the program. If there is an error while compiling your code it will show up in the tasks window of eclipse workbench with a red cross in the first column, description and line number where it occurs.
17. Navigate to Run/Run As/Java Application menu to run your program. Run your program a few times so that you can see it work. Try to understand what each line of code is actually doing. Congratulations! You've just written and run your first Java program (at least in CSCE 145).
18. Finally, email the `.java` file to both `jmvidal@gmail.com` and `shamik.usc@gmail.com` if you are in section 5, or `humayun.k1@gmail.com` if you are in section 6, with 145 Lab 1 somewhere in the Subject: line.

You should also install eclipse on your home machine.

Wednesday, August 18, 2010

Chaper 1 Video Lecture

Below is the video lecture that you must watch before coming to class on Tuesday August 24. Notice that to get the full HD resolution (1280 by 720) you have to watch the video in fullscreen mode, click on the fullscreen icon on the bottom right of the video to go to fullscreen. You should read Chapter 1 of the textbook before watching the video.

As you watch this videos, as well as all future videos I will show, make sure you stop it often and try by yourself to repeat what I did on the video. This is the only way to learn: by doing. No one can learn to program by simply watching a lecture.

If you have trouble installing eclipse or Java on your laptop, or getting the "Hello World" program to run please come to class on Tuesday (with your laptop, if needed) so we can fix it. You can also get from your fellow CSE students by visiting the ACM Student Chapter room in the second floor of Swearingen. They will be posting tutoring hours on their door.

I am also embedding the slides for this chapter below. No, I did not use these slides in my lecture and I do not recommend you read these instead of reading the book. They are only useful as reminders of what you have already read.

Friday, August 13, 2010

• We do not accept late work in this course. Assignments are made available to everyone at the same time and are due at the same time. No credit will be given for late assignments. Exceptions to the late policy may be made on an emergency basis. If there is an upcoming event that will prevent your handing in your assignment at the assigned time, you must email a request to your TA no less than 24 hours in advance. Absences due to health problems are usually not exceptions unless you are hospitalized at the time the assignment was due.
• Laboratory assignments will consist of short programs to be written in class. Lab work is due by the end of the lab meeting time and cannot be turned in later for credit.
• Homework assignments are larger programs to be written outside of class. They are to be sent in electronically before the indicated time on the day they are due, and they must be done individually.
• There will be three in-class tests (open book) during the semester as well as lab tests. The final exam will be cumulative.
• If you miss a test you will get 0 on that test. If you have a properly documented excuse for your failure to attend the test, and I approve it, then that percentage of the grade will be added to the final test.
Lab Assignments 20% 10% 15% 40% 15%

This is the first course in Computer Science and Engineering. It introduces the design of computer algorithms and their implementation in the Java programming language. The prerequisite is MATH 115 or enrollment in MATH 141. No prior programming experience is assumed, but you should already have some experience using a computer. The goals of the course are

• Introduce computational problem-solving techniques
• Introduce the use of computers for the construction of software solutions
• Introduce procedural abstraction
• Introduce data abstraction and elementary concepts of object-oriented programming
• Introduce the development of structured, modular algorithms and programs
• Introduce the Java programming language.
• Introduce a modern programming development environment: Eclipse.

I, Jose M. Vidal, will be teaching Sections 5 and 6. My office is at SWGN 3A51. The class homepage is the easy-to-remember http://www.csce145.com. Everything will be posted there.

Our Teaching Assistant(TAs) are: Shamik Roy Chowdhury <shamik.usc@gmail.com>, Humayun Kabir <humayun.k1@gmail.com>

Our Lab Assistants are: Caelan Reed Burris

Our texbook is Java: Introduction to Problem Solving and Programming (5th Edition) which we will be following closely. The textbook homepage has videos, exercise solutions, and other materials you will be interested in using.

The class meeting times are the following:

SectionMeeting TimeMeeting RoomTeacher
LectureTTH 9:30AM-10:20AM300 Main St. B213Jose Vidal
Section 5TTH 2:00PM- 3:55PMSwearingen 1D15 Shamik
Section 6TTH 4:10PM- 6:05PMSwearingen 1D15Humayun

Honor Code: Cheating is defined as giving or receiving unauthorized aid on any assignment, test, or project, or not documenting an outside source of information should one be used. It is unacceptable and will not be tolerated. All offenses will be reported to the Dean in accordance with the Carolina Community student handbook.

Academic sanctions are as follows. For the first offense, a student will receive a grade of 0 for the assignment. For the second offense, the student will receive a grade of F for the course.

Thursday, August 12, 2010

One Week To Go

It's one week before our first class. I'll soon update this site with information on this semester's class.