The Virtual Weight (vW) of an integer number (which consists of more than 1 digit) is the sum of the individual digits that are composing the number. For example, consider the following two numbers; 5638 and 1145, then the VW of each is calculated as following: vw(5638) = 5+6+3+8 = 22 vw(1145) = 1+1+4+5 = 11 Then, the VW can be classified as L (mean Low) or H (means High) using a specific cut-off value. For example, if the cut-off value is 15, then the VW of the number 5638 is H (High), and the VW of the number 1145 is L because 22 > 15 and 11 < 15 respectively Write a C++ program that: reads a positive integer n (where 5

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please help me as fast as possible

 

The Virtual Weight (vW) of an integer number (which consists of more than 1 digit) is the sum
of the individual digits that are composing the number. For example, consider the following
two numbers; 5638 and 1145, then the VW of each is calculated as following:
vw(5638) = 5+6+3+8 = 22
vw(1145) = 1+1+4+5 = 11
Then, the VW can be classified as L (mean Low) or H (means High) using a specific cut-off
value. For example, if the cut-off value is 15, then the VW of the number 5638 is H (High),
and the VW of the number 1145 is L because 22 > 15 and 11 < 15 respectively
Write a C++ program that:
reads a positive integer n (where 5<ns20) 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 L
or H using the above method. Use a user-defined function to handle this process (see
below, the description of FunctionI)
• Also the program will count how many Low and High VW's for the generated numbers
using another function named countVW(..) – see the description of the Function2.
• Finally, the program will compute the sum of the numbers which have Low VWs 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
v is 'L' or 'H' based on the given cut_off value in the parameter list. The function
returns one character either 'L' or 'H'. The prototype is given blow:
Prototype: char classify(int num, int cut_off);
//--use cut_off - 15
2. A function to count the classifications of the generated numbers. Every time is called,
the function increases (by 1) one of the counters that are defined in the main program
to count the L or H cases.
Prototype: void countW (int &counter);
//--notice the call by reference
Transcribed Image Text:The Virtual Weight (vW) of an integer number (which consists of more than 1 digit) is the sum of the individual digits that are composing the number. For example, consider the following two numbers; 5638 and 1145, then the VW of each is calculated as following: vw(5638) = 5+6+3+8 = 22 vw(1145) = 1+1+4+5 = 11 Then, the VW can be classified as L (mean Low) or H (means High) using a specific cut-off value. For example, if the cut-off value is 15, then the VW of the number 5638 is H (High), and the VW of the number 1145 is L because 22 > 15 and 11 < 15 respectively Write a C++ program that: reads a positive integer n (where 5<ns20) 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 L or H using the above method. Use a user-defined function to handle this process (see below, the description of FunctionI) • Also the program will count how many Low and High VW's for the generated numbers using another function named countVW(..) – see the description of the Function2. • Finally, the program will compute the sum of the numbers which have Low VWs 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 v is 'L' or 'H' based on the given cut_off value in the parameter list. The function returns one character either 'L' or 'H'. The prototype is given blow: Prototype: char classify(int num, int cut_off); //--use cut_off - 15 2. A function to count the classifications of the generated numbers. Every time is called, the function increases (by 1) one of the counters that are defined in the main program to count the L or H cases. Prototype: void countW (int &counter); //--notice the call by reference
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY