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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education