CSC 122 : Computer Science II

Programming Assignment #7

 

Due Thursday, December 11, in class

 

 

Set-Up:

You are working for a major software company in Bluemond, Washington, called MiniSoft.  This company is working with a famous mathematician and physicist named Dr. Stephen Falconing in England.  Dr. Falconing is doing some work that requires very large numbers – numbers that are beyond the capabilities of C++ to directly represent.

 

Now that you have successfully finished the bigint class, Dr. Falconing is ready to use it – or rather, for you to use it.  He would like to know the answers to the following questions:

·        What is the smallest integer value of n for which the value of  (n / k)! – that is, factorial of n / k – exceeds the value of 2n?  He would like answers for values of k = 2, 3, 4, and 5.  Since factorial is only defined for integers, you only need to consider values of n for which n / k is an integer.

·        What is the smallest value of n for which n! ends in k zeroes?  He would like answers for values of k = 1, 2, 3, 4, 5, and 6.

·        For a particular value of k, what is the smallest value of n such that 2n is larger than k!.  He would like answers for all value of k between 10 and 20 (inclusive).

 

Since he would like to make use of your bigint to answer further questions, he would also like you to write a calculator-type program.  Since he only uses HP calculators, the calculator program should make use of a stack structure.  This program should support the following operations:

 

1.      Push a bigint onto the stack (will need to be read from user as a string).

2.      Push the factorial of some integer (note integer – not a bigint) onto the stack.

3.      Push 2 raised to some integer (note integer – not bigint) power onto the stack.

4.      Add the two numbers on top of the stack together and push the answer back onto the stack.

5.      Multiply the top number on the stack by some integer.

6.      Clear the entire stack.

 

You should write this calculator program first and use it to answer the questions above.  You do not need to write another program to answer these questions.   Note that these questions will most likely have to be answered by trial and error.

 

 

Details:

 

For this assignment, you will use your bigint in a calculator-type program.  For this, you will be using the STL stack class.  Details of the stack class will be discussed in class.  We suggest you write the calculator program, make sure it works, and use it to answer Dr. Falconing’s questions.

 

You should work individually for this assignment.  You must turn in four things:

·        A printout of your bigint.h file.

·        A printout of your bigint.cpp file.

·        A printout of your project.cpp file (containing your calculator program).

·        A copy of your answers to Dr. Falconing’s questions, neatly presented.