Programming Assignment #3 -- DUE 11/2/01 11:00am

Key learning:  branches

A simple ALU has 3 logical functions and 1 arithmetic function.  The inputs of the ALU are A and B and will be loaded before selecting the function to be performed.  The result of the operation will appear at the output.

The ALU functions are:

1.    A AND B
2.    A OR B
3.    B NOT
4.    A + B

The program will first ask the user to input A and B.

Next, the program will print a numbered menu of the ALU's functions

The program will finally output the respective function performed and the result.

Example AND output:

Enter A: 1
Enter B: 1
1.    A AND B
2.    A OR B
3.    B NOT
4.    A + B
Choose a function: 1

Result: 1

OR example:

Enter A: 5
Enter B: 2
1.    A AND B
2.    A OR B
3.    B NOT
4.    A + B
Choose a function: 2

Result: 7

NOT example:

Enter A: 1
Enter B: 8
1.    A AND B
2.    A OR B
3.    B NOT
4.    A + B
Choose a function: 3

Result: 7

ADD example

Enter A: 192
Enter B: 256
1.    A AND B
2.    A OR B
3.    B NOT
4.    A + B
Choose a function: 4

Result: 448