Programming Assignment 1: Binary Arithmetic

Due Date: Wednesday, 02/05/03

Objectives: To test and refresh your knowledge of functions, file i/o, array manipulation, loops, and conditionals.

Problem Specification
Write a program that simulates unsigned 8-bit binary addition and multiplication. In writing your program, you may make the following assumptions:

Implementation Notes
You can use only functions in this program, not classes.

Your program will read input from a text file, test.txt, which has been provided for you. The test file contains five arithmetic problems. Each problem is formatted as follows:

operand1
operand2
operator

For example, the first problem in the test file is

12
10
*

Your program must convert each operand to an 8-bit binary number, carry out the specified operation (either binary addition or binary multiplication), and convert the solution (itself an 8-bit binary number) to decimal. The decimal solution should then be output to a neatly-formatted text file.

Required Testing
Your program must calculate solutions for each problem in the given test file.

Grading Criteria
Your grade for this program will be based on:

Extra Credit
Note: All extra credit must be thoroughly tested and such tests must be included in your program submission.