Introduction to Programming (22C:16, 22C:106)

Homework 5: Due Thursday, 3/6/97

Problem 1: [10 points]

This problem will make sense only if you read Project 2 handout. It is meant to get you started early on the project and you should be able to use the code you write for this problem, in your solution to Project 2.

Suppose that we have already defined the functions getOperand() and getOperator() as described in the handout for Project 2. Further suppose we have defined two other functions:

Suppose that the program you write for Project 2 is made up of 5 functions: the four defined above and the main() function. Now write the main() function for Project 2. As stated above, you may assume that the four functions (mentioned above) besides the main() function have all been defined. In other words, for this problem you do not have to write anything but the main() function.

Hint: Start with a working solution for Project 1. Replace each cin-statement that reads an operand such as

cin >> number;

by an equivalent statement:

number = getOperand();

Similarly, replace each cin-statement that reads an operator such as

cin >> op;

by an equivalent statement:

op = getOperator();

Then add statements that check for possible errors and call either the function printError1 or printError2 appropriately.

Problem 2: [10 points]

Write a program that computes the value of . Since is such a large number, you will have to use the BigInt class in your program. Along with your program attach a printout that shows the value of .



Sriram Pemmaraju
Thu Feb 27 11:36:47 CST 1997