### Assignment

Spring 2022, CS 1200-03
Assignment #5
Problem 1: Write a program that asks for an integer and prints out all factors. For example,
when the user enters 140, the program should print
2 2 5 7
Input validation: Do not accept negative integer values for the number.
Problem 2: Write a program that will predict the size of population of organisms. The
program should ask the user for the starting number of organisms, their average daily population increase (as a percentage), and the number of days they will multiply. A loop should
display the size of the population for each day.
Input validation: Do not accept a number less than 2 for the starting size of
the population. Do not accept a negative number for average daily population
increase. Do not accept a number less than 1 for the number of days they will
multiply.
Problem 3: This program asks you to validate the credit card. The last digit of credit card is
a check digit, which protects against switching two digits or an error in a single digit, both of
which are called transcription errors. The procedure below is how a credit card is validated.
Although many credit cards have sixteen digits, you use just 8 digits to understand how it
is done. Let us consider an 8 digit number, 47289897.
1. Beginning with the rightmost digit add every other number: 7 + 8 + 8 + 7 = 30
2. Double the remaining numbers: 18 18 4 8. Add all digits 1 + 8 + 1 + 8 + 4 + 8 = 30
3. Add the two sums from the frst two steps. 30 + 30 = 60
4. If the modulus of the sum with 10 is 0, the card is valid. 60 % 10 = 0, so this card is
valid.
5. What if the modulus is not 0? What if our number is 45289897. The frst sum will be
28. The second still is the same. In this case we should add all digits except the last
one, in the step 1. We will get 8 + 8 + 5 = 21 when we add the numbers in the second
step to the frst one, we will get 21 + 30 = 51.
6. To fnd the correct check digit, we then use the formula (10 – 51 % 10) % 10 = (10 –
1) % 10 = 9 % 10 = 9. The check digit should be 9, not 7.
Input Validation: Please do not accept negative values for a credit card. Those
who can handle 16 digits can work with credit card numbers on internet which
are only examples. Please do not use your own credit card numbers.
This assignment is due on Thursday, April 21 by 5:00 PM
Please write description of the program and make sure to indent your programs.
1