CIS 435 Lab 1

Points: 20 Due Date: Friday November 21, 2003

The main purpose of this lab is to make sure you know how to use your development environment and to proactice a llittle Java and problem solving skills. We might use this again in later labs, so write it like you will use it again.

You are going to make a small class to simulate a half-adder. This is a circuit that adds two bits together. The half part is because it doesn't handle a carry. The class will have a method that takes two arguments. These are the two bits it will add.

We are going to do this using logical functions, rather than arithmetical ones. These are the single & and single | operators. Here are some expressions that will result in the answer. In this, A is one of the inputs and B is the other. The first step is to AND A and B
x1 = !A (not A) & B

x2 = A & !B (not B)

x3 = A & B (This is the carry)

x4 = x1 | x2 (This is the sum)

There will be two other methods, one to retrieve the sum and one to retrieve the carry.

You can construct this as a single class that also contains the main() method.


You should turn in a listing of the program. Staple the cover sheet to that.


Since this is the main class in the application, all the methods you write and the data variables you make must be marked static, like the main() method is. Also, the not (!) operator doesn't work on integers in Java. You will have to write a method that does this. Remember not(1) is 0 and not(0) is 1;

Think about how you will do this so you can ask questions.
ASK if you have any questions.