CS 141 Programming Assignment 4

Big Integers


Overview

We've talked about how int variables are finite. They cannot handle really large integers. In this assignment, we are going to write code to handle very large integers.

We are going to represent very large integers as an array of digits (ints 0-9) and write functions to add and substract them.

The following directory contains a set of input files (valid and invalid) that your program should handle. You should properly return the sum or difference for correct files and report an error for invalid files.

You should write a struct or class to represent bigNumbers as an array of digits. Like we saw with C-strings, you should keep track of the total length of the array and the number of digits you are actually using.

You should implement addition and subtraction on your bigNumbers. You can do it with functions. You could do it with overloaded operators but you don't have to.

You can declare your struct or class in the same cpp file with your main program if you want to or you can tackle splitting it into multiple files.

You will need to write a main program that will read input files containing equations and user your bigNumbers to compute the correct answers.

In addition to your source code, you should also contribute two testfiles - good_YOURUSERNAME.txt and bad_YOURUSERNAME.txt. The good file should be a valid input file and the bad file should be an invalid input file. I suggest that you write more testcases than that to prove to yourself that your code is working.

Remember to start early!! Little logistical problems solved with a quick question or an email, turn into major crisis the night before the due date when no one is available to help. Determine which office hours fit your schedule and plan to start the assignment before those!!! Then come in for help if you need it.


What to Turn In

You should turn in the assignment to the directory /afs/cu/class/cs141/students/YOUR_USERNAME/prog4 (e.g. I would put mine in /afs/cu/class/cs141/students/jmatthew/prog4).