Write the function definitions for the following five function prototypes shown in Listing-1 called in main. Function definitions go below main starting at the comment shown in Listing-2

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

Write the function definitions for the following five function prototypes shown in Listing-1 called
in main. Function definitions go below main starting at the comment shown in Listing-2

Listing 2: main
1 #include <iostream>
2 #include <string >
3 #define CATEGORIES 5
4
5 // Prototypes go here
6.
7 // main is shown complete, DO NOT MODIFY
8 int main (){
std:: string categories [CATEGORIES];
double values [CATEGORIES]; double total{ 0.0 }; int lcl{ 0 };
9.
10
11
12
while (true) {
get_category (categories);
get_values (values, categories);
compute_total (total, values);
get_longest_category_name (lcl, categories);
13
14
15
16
17
<< "\nCategories as
a Percentage of \
the Total (category_amount/" << total
18
std::cout
19
<< ")\n";
20
std::cout
くく
21
\n";
bar_chart (categories, values, lcl, total);
<< "\nEnter y to
23
std :: cout
another bar chart, \
%3D
create
24
or any other key to exit: ";
25
std:: cout <<"\n";
std :: string response; std:: cin >> response;
if (response != "y")
26
27
break;
28
1cl
= 0; total
0.0;
29
}//while
30 }//main
31 //
32 // Implementations go below
33 //
Transcribed Image Text:Listing 2: main 1 #include <iostream> 2 #include <string > 3 #define CATEGORIES 5 4 5 // Prototypes go here 6. 7 // main is shown complete, DO NOT MODIFY 8 int main (){ std:: string categories [CATEGORIES]; double values [CATEGORIES]; double total{ 0.0 }; int lcl{ 0 }; 9. 10 11 12 while (true) { get_category (categories); get_values (values, categories); compute_total (total, values); get_longest_category_name (lcl, categories); 13 14 15 16 17 << "\nCategories as a Percentage of \ the Total (category_amount/" << total 18 std::cout 19 << ")\n"; 20 std::cout くく 21 \n"; bar_chart (categories, values, lcl, total); << "\nEnter y to 23 std :: cout another bar chart, \ %3D create 24 or any other key to exit: "; 25 std:: cout <<"\n"; std :: string response; std:: cin >> response; if (response != "y") 26 27 break; 28 1cl = 0; total 0.0; 29 }//while 30 }//main 31 // 32 // Implementations go below 33 //
2. Write the function definitions for the following five function prototypes shown in Listing-1 called
in main. Function definitions go below main starting at the comment shown in Listing-2
Listing 1: prototypes
1 //function 1: reads five category names
into the cat array
2 void get _category (std : : string
cat [CATEGORIES]);
3
//function 2: gets five values for each category
5 void get_values (double values [CATEGORIES], std::string cat[CATEGORIES]);
4
6.
7 //function 3: computes the total value and stores in total
8 void compute_total(double& total, double vals [CATEGORIES]);
9.
10 //function 4:
computes the longest category name
and stores in longest
11 void get_longest_category_name (int& longest, std:: string cat [CATEGORIES]);
12
13 //function 5: prints to std:cout the five category bar chart
14 void bar_chart (std:: string cat [CATEGORIES], \
15
double values [CATEGORIES], int lcl, double total);
Transcribed Image Text:2. Write the function definitions for the following five function prototypes shown in Listing-1 called in main. Function definitions go below main starting at the comment shown in Listing-2 Listing 1: prototypes 1 //function 1: reads five category names into the cat array 2 void get _category (std : : string cat [CATEGORIES]); 3 //function 2: gets five values for each category 5 void get_values (double values [CATEGORIES], std::string cat[CATEGORIES]); 4 6. 7 //function 3: computes the total value and stores in total 8 void compute_total(double& total, double vals [CATEGORIES]); 9. 10 //function 4: computes the longest category name and stores in longest 11 void get_longest_category_name (int& longest, std:: string cat [CATEGORIES]); 12 13 //function 5: prints to std:cout the five category bar chart 14 void bar_chart (std:: string cat [CATEGORIES], \ 15 double values [CATEGORIES], int lcl, double total);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 3 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