Due dates: >>You must turn it in with the turnin program from your account for this class by midnight at the end of the day Sunday Oct 13. (If you miss that deadline, you can turn it in up to 24 hours late, but with a penalty.) >>You must complete an interview for assignment 2 by the end of the day Friday October 18. Note that there is no grace period on the interview deadline. Also note that there are no proctors in the labs Friday after about 6pm. Modified on October 4, 1996 READ THE WHOLE FILE AND DO SO CAREFULLY. You can work on this as soon as you want, but 1. Do the reading in the Savitch text if you are working ahead 2. DO NOT TURN THIS IN WITH THE turnin PROGRAM BEFORE 8 AM SATURDAY, OCTOBER 5. If you finish before then, just wait a few days to turn it in. Also, check for changes before turning it in. CSE 9A UCSD Fall, 1996 Assignment 2 Due date: To be announced Reading: Chapters 1 and 2 and Section 3.2 of Chapter 3, all in the Savitch text Programming: Programming project 8 on page 98 (Chapter 2). You may work in teams of two people on this; the two team members do not have to be in the same section. You may work alone if you prefer. Details: >The first payment is due one month after the date of purchase. If you make N payments and after N payment, your balance is zero, then we will say it takes N months (not N+! months or anything else). >Use the const modifier to create names for each of the following constants: interest rate (you may wish to use the monthly rate.) purchase price monthly payment amount >IMPORTANT ADDED DETAIL: >One reason for using the const modifiers is so that you can later change any or all of the values for the interest rate, purchase price, and/or monthly payment. (This does require that you recompile.) However, for some values of these constants, the loan will never be payed off. If the payment is less than or equal to the monthly interest, the loan is never payed off and the program might have an infinite loop. Include a check that will end the program and write out a warning if the loan will never be paid off. The file hw02v2.o contains object code for a version of the program with the purchase price changed to $4000. This loan would never be paid off. (The file hw02.o has object code for the version you will turnin.) >Note that you cannot uses fractions of pennies in this accounting. If the interest due is $14.573 then you are charged $14.58 in interest. Note that it is raised to the next full penny and not simply rounded. This makes calculating the monthly interest a little bit tricky. Suppose the monthly interest rate is given by: const double rate = 0.015;//Monthly interest rate as a fraction The monthly interest should be balance*rate. But balance*rate may include a fraction of a penny. The following expression will change any fraction of a penny to a whole penny: monthly interest = (ceil(balance*rate*100))/100.0; You can use this formula without understanding it, but it is easy to explain. suppose balance*rate is 14.573 then balance*rate*100 is 1457.3 ceil is the "ceiling function" which takes any fraction and moves it to the next whole number, so ceil(1457.3) is 1458 1458/100.0 is 14.58 So, this changes 14.573 to 14.58 as desired. >You will need to put the following at the top of your file in order to use the ceil function: #include you put on a separate line right next to #include (Note that this is all you need to do with CC compiler. With the g++ compiler you need to do more. If you want to try the g++ compiler see the file g++.math in the public directory.) >Be sure to use the "magic formula" (pp 50-51) to output dollar amounts in a nice format. >Be sure to include a comment at the top similar to the one on p.89. >Be sure to follow the style of the programs in the Savitch text.