Question: Problem: Given a positive integer as input, calculate the following and determine if they are multiples: 1. Remove the digit in the ones place of

Problem: Given a positive integer as input, calculate the following and determine if they are multiples: 1. Remove the digit in the ones place of the number and test whether it is a multiple of the original value. Repeat this task until the number reaches zero. 2. Sort the digits in the number from largest to smallest and test whether it is a multiple of the original value. 3. Sort the digits in the number from smallest to largest and test whether it is a multiple of the original value. 4. If the number of digits in the input is odd then exchange the digits at the highest and lowest position of the original number and test whether it is a multiple of the original value (example: 38425 becomes 58423). If the number of digits in the input is even then exchange the middle two digits of the original number and test whether it is a multiple of the original value (example: 1234 becomes 1324).

Example Execution #1: Enter a positive integer value: 264802 Testing value 26480, is not found to be a multiple. Testing value 2648, is not found to be a multiple. Testing value 264, is not found to be a multiple. Testing value 26, is not found to be a multiple. Testing value 2, is found to be a multiple. Testing value 864220, is not found to be a multiple. Testing value 22468, is not found to be a multiple. Testing value 268402, is not found to be a multiple. Example Execution #1 Explained: 1. The first five lines of output generated correspond to the repeated removal of digits and comparing the result with the value input. 2. The value 864220 is the sorted value (largest to smallest) of the digits contained in the value input. 3. The value 22468 is the sorted value (smallest to largest) of the digits contained in the value input. 4. Because the number of digits in the input is even the middle two digits (4 and 8) are exchanged and the new number compared to the input. Example Execution #2: Enter a positive integer value: 1357246 Testing value 135724, is not found to be a multiple. Testing value 13572, is not found to be a multiple. Testing value 1357, is not found to be a multiple. Testing value 135, is not found to be a multiple. Testing value 13, is not found to be a multiple. Testing value 1, is found to be a multiple. Testing value 7654321, is not found to be a multiple. Testing value 1234567, is not found to be a multiple. Testing value 6357241, is not found to be a multiple. Example Execution #2 Explained: 1. The first six lines of output generated correspond to the repeated removal of digits and comparing the result with the value input. The number of digits in the original input will dictate the number of lines of output that will be generated in this first series of comparisons. 2. The value 7654321 is the sorted value (largest to smallest) of the digits contained in the value input. 3. The value 1234567 is the sorted value (smallest to largest) of the digits contained in the value input. 4. Because the number of digits in the input is odd the first and last digits (1 and 6) are exchanged and the new number compared to the input. Example Execution #3 (input validation requirement demonstrated): Enter a positive integer value: 0 Error! Positive values only! Enter a positive integer value: 123000 Testing value 12300, is found to be a multiple. Testing value 1230, is found to be a multiple. Testing value 123, is found to be a multiple. Testing value 12, is found to be a multiple. Testing value 1, is found to be a multiple. Testing value 321000, is not found to be a multiple. Testing value 123, is found to be a multiple. Testing value 120300, is not found to be a multiple. Example Execution #4 (input validation requirement demonstrated): Enter a positive integer value: -4 Error! Positive values only! Enter a positive integer value: 2222 Testing value 222, is not found to be a multiple. Testing value 22, is found to be a multiple. Testing value 2, is found to be a multiple. Testing value 2222, is found to be a multiple. Testing value 2222, is found to be a multiple. Testing value 2222, is found to be a multiple. Example Execution #5: Enter a positive integer value: 91 Testing value 9, is not found to be a multiple. Testing value 91, is found to be a multiple. Testing value 19, is not found to be a multiple. Testing value 19, is not found to be a multiple. Example Execution #6: Enter a positive integer value: 244 Testing value 24, is not found to be a multiple. Testing value 2, is found to be a multiple. Testing value 442, is not found to be a multiple. Testing value 244, is found to be a multiple. Testing value 442, is not found to be a multiple. Example Execution #7: Enter a positive integer value: 3 Testing value 3, is found to be a multiple. Testing value 3, is found to be a multiple. Testing value 3, is found to be a multiple. Example Execution #7 Explained: The three lines of output generated represent the two sorted values (smallest to largest, largest to smallest) and the first and last digits exchanged because the number of digits in the input is odd. There are no comparisons from (1) as described in the problem because the input is only a single positive digit

Additional Requirements: 1. Add the homework assignment header file to the top of your program. A description of your program will need to be included in the assignment header. This particular header can be added to your file by entering hhw while in command mode in vi. 2. Each example execution represents a single test of your program. Your program is expected to accept input and produce output in the same manner demonstrated above. Input must be validated to be positive, the user should be given an unlimited number of opportunities to enter an acceptable value. Your program will only be tested with values that can be stored in an int variable. Do not add any bonus features not demonstrated in the example executions provided. 3. Course standards prohibit the use of programming concepts not yet introduced in lecture. For this assignment you can consider all material in the first six chapters of the book, notes, and lectures to be acceptable for use. The use of arrays are not permitted on this assignment. You may use code found in the course note packet for this assignment. Please cite your source in the header of each user-defined function. 4. For this assignment you will be required to implement the user-defined functions (from chapter 4). Failing to follow course standards as they relate to good user-defined function use will result in a zero for this assignment.

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!