Write a function for the user to enter a positive integer n with a value between 10 and 1000. If entered correctly, the function generates a list containing n random values ​​that do not overlap between 1 and 5000 and the function returns the newly created list. Conversely, if entered incorrectly, the program will ask to re-enter until it is correct. Cases where n is considered incorrect: (i)- If the user enters a non-integer data type (like string, float, bool, ...) The program will display the error message 'Must enter a positive integer. Requires re-entry'. (ii)- If the input value is of the correct integer data type but the value is not in the range 10 to 1000, the program gives the error 'Only values ​​between 10 and 1000. Re-enter required'. Installation requirements: must use the try ... except statement to handle possible exceptions in the program.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.5: Case Studies
Problem 3E
icon
Related questions
Question

Ex1: a) Write a function for the user to enter a positive integer n with a value between 10 and 1000. If entered correctly, the function generates a list containing n random values ​​that do not overlap between 1 and 5000 and the function returns the newly created list. Conversely, if entered incorrectly, the program will ask to re-enter until it is correct. Cases where n is considered incorrect:
(i)- If the user enters a non-integer data type (like string, float, bool, ...)
The program will display the error message 'Must enter a positive integer. Requires re-entry'.
(ii)- If the input value is of the correct integer data type but the value is not in the range
10 to 1000, the program gives the error 'Only values ​​between 10 and 1000. Re-enter required'.
Installation requirements: must use the try ... except statement to handle possible exceptions
in the program.


b) Write a function that lists the amicable numbers in the list just created in a)

(If there are no amicable numbers in the list, print the message: ''The list does not contain friendly numbers.'')

c) Write a function that lists the strobogrammatic numbers in the list just created in  a).

(If there are no strobogrammatic numbers in the list, print the message: ''The list does not contain strobogrammatic numbers.'')

d) Write a function that lists the lucky numbers in the list just created in a)
Suppose to determine whether the process of finding Lucky number will last indefinitely, person
We repeat this search up to 100 times. Therefore, if the iterative process to find is more than 100 times, then
the program can conclude that the number is not Lucky number.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr