hw1-factor.c,
hw1-pi.c,
hw1-bank.c
.
These programs are to be electronically submitted by using the submit program on csa. The code you submit should conform with the program assignment guidelines.
The only input is an integer (use long to allow for
larger numbers). Your program must display the factorization.
Files: hw1-factor.c.
One change from the assignment listed. Your program should have the user input the number of rectangles to use (the book says use 100). What will your program do if the user enters 0 or a negative integer?
Files: hw1-pi.c.
One good way to save a large sum of money is to deposit each month a fixed sum of money into an interest bearing account (perhaps after making an initial deposit to open the account). Especially if the interest rate is relatively high, the money invested can grow quite significantly over time. This exercise we have you write a program which demonstrates this. (If you do not know how to compute interest in such an account, I have included an example below.)
Your program should repeatedly
Use a negative interest rate as a sentinal to indicate that the program should terminate. In this case, the program should not request additional inputs.
Run the program with some resonable inputs. (Try $50 per month at 5% interest for 10 or 30 years, for example.) What happens if you enter a negative initial deposit? a negative payment? Be sure to include comments about these situations in your program output. Your output should look something like the following:
Instructions go here. Be sure to add comments about negative input values. Enter interest rate (negative value to quit): 10 Enter initial amount: $1000 Enter payment amount: $100 Enter number of years: 7 initial amount: $1000.00; interest rate: 10.0000%; monthly payment: $100.00 yrs mos balance 0 0 1000.00 0 1 1108.33 0 2 1217.57 0 3 1327.72 0 4 1438.78 0 5 1550.77 0 6 1663.69 0 7 1777.56 0 8 1892.37 0 9 2008.14 0 10 2124.87 0 11 2242.58 1 0 2361.27 2 0 3865.08 3 0 5526.36 4 0 7361.60 5 0 9389.02 6 0 11628.73 7 0 14102.96 Enter interest rate (negative value to quit): -1
To get you started, here is a shell you
may use. It includes some of the basic structure, but you need to fill
in most of the comments and code. There is also an example executable
for this assignment in ~cs113/rpruim/F97/bin/ex1-bank.
If your environment is set up correctly (so that
~cs113/rpruim/F97/bin/ is in your path) you can run
this program by typing ex1-bank.
Files:
hw1-bank.c
Makefile.
Makefile.a1,
you will have to use the mv (short for move)
command to rename it by typing
mv Makefile.a1 Makefile
cp command to copy it by typing
cp Makefile.a1 Makefile
make.
You can also use this Makefile to compile individual programs by typing,
for example, make hw1-bank. The obvious generalization works
for the other files as well.
I have provided a little test to see that your programs run correctly on
inputs of the general form which will be used for grading. To run the
test, type make test. If you want to have all of the output
put into a file instead of onto the screen, type
make test >& test.out
Can you figure out by looking at the Makefile what make tidy
and make scratch do? Try it and find out.
Do not allow your work to be used by others:
Warning: If someone cheats by using your work, you will also be penalized.