Question: Design a program called IntFun.py which reads in a non-negative integer from the user. The user will then be prompted with a menu of choices

Design a program called IntFun.py which reads in a non-negative integer from the user. The user will then be prompted with a menu of choices (this menu should be repetitively displayed until the user chooses to quit): You must implement #1 and #5 and TWO of #2, #3,and #4. (SEE EXTRA CREDIT)

Your menu will include these choices (stub out the one you dont implement.)

  1. Enter a new number
  2. Print the number of odd digits, even digits and zeros in the integer
  3. Print the prime numbers between 2 and the integer
  4. Print the sum of the digits of the integer
  5. Quit the program

PROGRAM PARTICULARS:

  • When the program starts up, ask the user for a non-negative integer. After the user enters the non-negative integer, display the above menu. Remember the user can choose to do #2, #3, and #4 on the same number. Meaning, once you have the number from the user do not make the user enter a new number each time. The user can keep the same number until the user selects option 1 (see example output below.)
  • There must be error checking on the input integer: if it is negative, the program will print an error message and re-prompt. This process will continue until valid input is entered. You may assume an integer of some form will be entered by the user.
  • There must be error checking on the menu choice entered: if the user enters a choice not on the menu, the program will print an error message, re-display the menu and re-prompt. This process will continue until valid input is entered.
  • No string variables are allowed.
  • No built-in methods for integer manipulation are allowed.
  • You may assume that no integer entered will be greater than the maximum integer size for type int.

HINTS:

  • First, solve the primary problems one at a time, testing each one separately. (Make sure that your algorithm works for single-digit numbers - including zero!). Design things modularly.
  • Solve the input and error checking problems once the others are solved and tested. EXTRA CREDIT: 10 points: implement all three! (NOTE: if you implement the extra credit, be sure and document that you are doing so -- if you do not, you will not be given credit for it!) TURN IN:(via the Canvas system) A .py file - hopefully you understand the naming scheme. PetersChw3.py Your code

SAMPLE OUTPUT:

Welcome to Integer Fun. Please enter a non-negative integer --> -12

I am sorry that is not a non-negative integer. Please enter a non-negative integer --> 120

Please select from the following menu choices.

  1. Enter a new number
  2. Print the number of odd, even and zero digits in the integer
  3. Print the prime numbers between 2 and the integer
  4. Print the sum of the digits of the integer
  5. Quit the program

Choice --> -6

I am sorry that is an invalid menu choice. Please try again

Please select from the following menu choices.

  1. Enter a new number
  2. Print the number of odd, even and zeros in the integer
  3. Print the prime numbers between 2 and the integer
  4. Print the sum of the digits of the integer
  5. Quit the program

Choice --> 2

Your results are: odd - 1 even - 1 zero(s) - 1

Please select from the following menu choices.

  1. Enter a new number
  2. Print the number of odd, even and zeros in the integer
  3. Print the prime numbers between 2 and the integer
  4. Print the sum of the digits of the integer
  5. Quit the program

Choice --> 4 The sum of the digits in the number 120 is 3 Please select from the following menu choices.

  1. Enter a new number
  2. Print the number of odd, even and zeros in the integer
  3. Print the prime numbers between 2 and the integer
  4. Print the sum of the digits of the integer
  5. Quit the program

Choice --> 1 Please enter a non-negative integer --> 10 Please select from the following menu choices.

  1. Enter a new number
  2. Print the number of odd, even and zeros in the integer
  3. Print the prime numbers between 2 and the integer
  4. Print the sum of the digits of the integer
  5. Quit the program

Choice --> 2

Your results are: odd - 1 even - 0 zero(s) - 1

Please select from the following menu choices.

  1. Enter a new number
  2. Print the number of odd, even and zeros in the integer
  3. Print the prime numbers between 2 and the integer
  4. Print the sum of the digits of the integer
  5. Quit the program

Choice --> 5 Thank you and have a nice day

Python 3 to be used. Thanks

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 Databases Questions!