Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to design a program which reads in a non-negative integer from the user. The user will then be prompted with a menu of

I need to design a program 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):

My menu will include these choices:

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 the positive integer. After the user enters the positive 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. I have added a sample output of what the program should execute like. (See 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 (char arrays) or any other kinds of array variables are allowed.

No built-in methods for integer manipulation are allowed. You may use pow( ) if you feel it is necessary.

You may assume that no integer entered will be greater than the maximum integer size for type int.

You must use functions for this assignment. The main function will be very small, it will contain function calls and a do while loop.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

=+j Explain IHRMs role in global HR research.

Answered: 1 week ago

Question

=+j Describe an effective crisis management program.

Answered: 1 week ago