Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

IN C++ PLEASE:

Refer to the sample code provided and output for how the application will run.
Program Description and Functionality: Provide the following in your source file:
1. Comments at the top of your .cpp file.
2. Write the function definitions for the following five function prototypes shown in Listing-1 that are
called from main. Write the function definitions below main starting at the comment shown in
Listing-2
Listing 1: prototypes
// function 1: reads 25 category names into the cat array
void get_category ( std :: string cat [ CATEGORIES ]);
// function 2: gets 25 values for each category
void get_values ( double values [ CATEGORIES ] , std :: string cat [ CATEGORIES ]);
// function 3: computes the total value and stores in total
void compute_total ( double & total , double values [ CATEGORIES ]);
// function 4: computes the longest category name and stores in longest
void get_longest_category_name (int & longest , std :: string cat [ CATEGORIES ]);
// function 5: prints to std : cout the 25 category bar chart
void create_bar_chart ( std :: string cat [ CATEGORIES ] , \
double values [ CATEGORIES ] , int lcl , double total );

Listing 2: main
# include <iostream >
# include <string >
# define CATEGORIES 25
// Prototypes go here
int main (){ // main is shown complete , DO NOT MODIFY
std :: string categories [ CATEGORIES ];
double values [ CATEGORIES ]; double total { 0.0 }; int lcl { 0 };
while ( true ) {
get_category ( categories );
get_values ( values , categories );
compute_total ( total , values );
get_longest_category_name ( lcl , categories );
std :: cout << "\ nCategories as a Percentage of \
the Total ( category_amount /" << total << ")\n";
std :: cout << " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
~~~~~~~~~~~~~~~~~~~~~~~~~~~\ n";
create_bar_chart ( categories , values , lcl , total );
std :: cout << "\ nEnter y to create another bar chart , \
or any other key to exit : ";
std :: string response ; std :: cin >> response ; std :: cout <<"\n";
if ( response != "y")
break ;
lcl = 0; total = 0.0;
}// while
}// main
// Implementations below main

Example usage:
>A03.exe
Enter in the category names for your twentyfive-bar bar chart:
Red Green Orange Yellow Blue
How many in the Red category? 10
How many in the Green category? 20
How many in the Orange category? 30
How many in the Yellow category? 5
How many in the Blue category? 35
Categories as a Percentage of the Total (category_amount/100)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Red **********10.00
Green ********************20.00
Orange ******************************30.00
Yellow *****5.00
Blue ***********************************35.00
Enter y to create another bar chart, or any other key to exit: y
Enter in the category names for your twentyfive-bar bar chart:
Eight Fifty-Five Nineteen One-Hundred 2
How many in the Eight category? 150
How many in the Fifty-Five category? 200
How many in the Nineteen category? 350
How many in the One-Hundred category? 175
How many in the 2 category? 50 

 

IN C++ PLEASE

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Engineering
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY