Question: Question 3 : Create a program that checks whether a number ( between 1 and 5 0 0 0 , exclusive ) is a prime

Question 3: Create a program that checks whether a number (between 1 and 5000, exclusive) is a prime number and displays the total number of factors if it is not a prime number. Use the screenshot as a reference. (30 pts .)
```
Prime Number Checker
Please enter an integer between 1 and 5000: 1
Invalid integer. Please try again.
Please enter an integer between 1 and 5000: 2
2}\mathrm{ is a prime number.
Try again? (y/n): y
Please enter an integer between 1 and 5000: 3
3 is a prime number.
Try again? (y/n): y
Please enter an integer between 1 and 5000: 4
4 is NOT a prime number.
It has 3 factors.
Try again? (y/n): y
Please enter an integer between 1 and 5000: 6
6 is NOT a prime number.
It has 4 factors.
Try again? (y/n): n
Bye!
```
(3a) A prime number is only divisible by two factors (1 and itself). For example, 7 is a prime number because it is only divisible by 1 and 7. If the number is not a prime number, the program should display its number of factors. For example, 6 has four factors (1,2,3, and 6).(4 pts.)
(3b) Store the code that gets a valid integer for this program in its own function. (8 pts.)
- Assume the user will enter an integer. However, if the number is out of range, display this message: "Invalid integer. Please try again."
(3c) Store the code that calculates the number of factors for a number in its own function. (8 pts.)
(3d) Store the rest of the code that gets input and displays output in the main() function. If needed, divide this code into functions whenever you think it would make that code easier to read and maintain. (10 pts .)
- The program should continue only if the user enters "y" or "Y" to continue.
Question 3 : Create a program that checks whether

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!