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 # include # 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
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
Step by step
Solved in 3 steps with 3 images