The Significance (S-value) of an integer number is the number of the digits that are composing the number. For example, consider the following two numbers; 5638 and 1145, then the S- value of each is calculated as following: S(5638) = 4 S(145) = 3 Then, the S can be classified as I (means Important) or N (means Not Important) using a specific magnitude value. For example, if the magnitude value is 4, then the S-value is I for all values greater or equal to 4; otherwise the S-value is N. So, in the above example S-value is I for the number 5638, and it is N for the number 145. Write a C++ program that: reads a positive integer n (where 2

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
icon
Concept explainers
Question
The Significance (S-value) of an integer number is the number of the digits that are composing
the number. For example, consider the following two numbers; 5638 and 1145, then the S-
value of each is calculated as following:
S(5638) = 4
S(145) = 3
Then, the S can be classified as I (means Important) or N (means Not Important) using a
specific magnitude value. For example, if the magnitude value is 4, then the S-value is I for all
values greater or equal to 4; otherwise the S-value is N. So, in the above example S-value is I
for the number 5638, and it is N for the number 145.
Write a C++ program that:
reads a positive integer n (where 2<n<10) from the user. If the user enters invalid
number, then the program should continue prompting until he/she enters a valid number
within the specified range.
Then, the program should generate n random numbers using the built-in rand()
function.
• Every time a random number is generated, the program will classify that number as I
or N using the above method. Use a user-defined function to handle this process (see
below, the description of Function1)
• Also the program will count how many Important and Not Important S-values for the
generated numbers using another function named countS(...) – see the description of
the Function2.
• Finally, the program will compute the sum of the numbers which have Not Important
S-values only and display the result as illustrated in the sample output.
The program must use at least two functions as following:
1. A function to process the given number in the parameters list, and specify whether its
S-value is I or N based on the given magnitude value in the parameter list. The function
returns the character I if S-value is greater than or equal the magnitude; otherwise it
Transcribed Image Text:The Significance (S-value) of an integer number is the number of the digits that are composing the number. For example, consider the following two numbers; 5638 and 1145, then the S- value of each is calculated as following: S(5638) = 4 S(145) = 3 Then, the S can be classified as I (means Important) or N (means Not Important) using a specific magnitude value. For example, if the magnitude value is 4, then the S-value is I for all values greater or equal to 4; otherwise the S-value is N. So, in the above example S-value is I for the number 5638, and it is N for the number 145. Write a C++ program that: reads a positive integer n (where 2<n<10) from the user. If the user enters invalid number, then the program should continue prompting until he/she enters a valid number within the specified range. Then, the program should generate n random numbers using the built-in rand() function. • Every time a random number is generated, the program will classify that number as I or N using the above method. Use a user-defined function to handle this process (see below, the description of Function1) • Also the program will count how many Important and Not Important S-values for the generated numbers using another function named countS(...) – see the description of the Function2. • Finally, the program will compute the sum of the numbers which have Not Important S-values only and display the result as illustrated in the sample output. The program must use at least two functions as following: 1. A function to process the given number in the parameters list, and specify whether its S-value is I or N based on the given magnitude value in the parameter list. The function returns the character I if S-value is greater than or equal the magnitude; otherwise it
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Control Structure
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning