Due 1:00 PM, Wednesday, 02 May 2018 CPSC 101b Homework #10 Programming With Loops Note: Your solutions to these problems should be sent as attachments in a message to sce@cs.yale.edu by the time+date above. The subject line should contain the phrase "CPSC 101". The name of the program should be that specified in brackets at the start of the problem. REMINDER: When discussing an assignment with other students, you may write on a board or a piece of paper, but you may not retain any written or electronic record of the discussion. Moreover, you must engage in a full hour of mind- numbing activity (e.g., watching back-to-back episodes of Gilligan's Island) before you work on the assignment again. This ensures that you can reconstruct what you learned from the discussion, by yourself, using your own brain. The same rule applies to nonstudents and on-line sources. 1. (10 points) [csl.html] Congratulations! You just won first prize in the Connecticut State Lottery---$10,000 each month tax-free for the next ten years (starting in January 2019 and continuing through December 2028). Being a prudent person, you decide to have half of each month's check deposited in a savings account which returns 6%/year simple interest compounded monthly (i.e., the monthly interest rate is .5%). (The money is deposited at the start of each month; interest on the resulting balance is added to the account at the end of the month.) But on second thought you reconsider and decide to spend the entire December check each year on a ski vacation in the Swiss Alps instead of having half deposited in the bank. Output to the document window (i.e., use document.write() to print) the amount of money (with 2 digits to the right of the decimal point) you will have in the bank at the end of each of the ten years. Hint: The amount at the end of 2020 should be approximately $117435.64. 2. (10 points) Write a program to solve ONE of the following problems: a. [prime.html] A prime number is an integer that is evenly divisible (i.e., the remainder on division is zero) only by itself and 1. Prompt for a number N and print the values of the first N odd primes in the document window, separated by spaces. If N is large enough, your sequence will begin 3, 5, 7, 11, 13, 17, 19, ... . b. [palint.html] A palindromic number is an integer that reads the same backward as forward. For example, 12321 and 1001 are palindromic integers, but 1210 is not. Prompt for an integer and print an alert with "Palindrome" if reversing the digits leaves the number unchanged and "Not" otherwise. Hint: Can you compute the number where the digits are reversed? Note: You may assume that the number entered is non-negative; that it has _at_most_ 15 digits (which will ensure that all digits are stored correctly); and that the leading digit is nonzero unless the number is 0 (i.e., any leading 0's are ignored). c. [cc.html] People often give credit card numbers over the Internet. To stop them from making up numbers at random, credit card issuers put a check digit in the ones' place. Prompt for a credit card number and print an alert with the credit card number and the word "Valid" if it is valid and "Invalid" otherwise. Note: You must read the entire number using a single prompt(), but may assume that the number entered is non-negative and has _at_most_ 15 digits (which will ensure that all digits are stored correctly). 3. (1 point) How many hours did it take you complete the first two problems? Optional Reading: Kernighan, Chapter 12 (Cryptography); and MacCormick, Chapters 4 (Public Key Cryptography) and 9 (Digital Signatures). CPSC-101b-04/18/18