Please use this template /*************************************************************************   predefined classes, functions, structures *************************************************************************/ #include        // cin, cout // missing several using namespace std; /*************************************************************************   global formatting constants *************************************************************************/ const unsigned int AUTHOR_COLUMN_WIDTH = 25; const unsigned int TITLE_COUNT_COLUMN_WIDTH = 18; /*************************************************************************   function prototypes *************************************************************************/ void showMenu(); void displayFirstFileLine(const string file_name); void displayFirstAuthorName(const string file_name); void displayFirstAuthorInformation(const string file_name); void displayAllAuthorInformation(const string file_name); void displayFormattedTableNoAverage(const string file_name); void displayEntireFormattedTable(const string file_name); /*************************************************************************   main() definition *************************************************************************/ /*************************************************************************   main() definition *************************************************************************/ int main() {         // loop through menu     unsigned int user_choice;     const string FILE_NAME = "author_titles_data.txt";          // get first user choice     showMenu();          cout << "Enter your choice [1 to 7]: ";     cin >> user_choice;     while (user_choice < 7)     {         cout << endl;                  switch (user_choice)         {             case 1:                 displayFirstFileLine(FILE_NAME);                 break;             case 2:                 displayFirstAuthorName(FILE_NAME);                 break;             case 3:                 displayFirstAuthorInformation(FILE_NAME);                 break;             case 4:                 displayAllAuthorInformation(FILE_NAME);                 break;             case 5:                 displayFormattedTableNoAverage(FILE_NAME);                 break;             case 6:                 displayEntireFormattedTable(FILE_NAME);                 break;             default:                 // nothing                 break;         }                cout << endl;       // get next user choice       showMenu();       cout << "Enter your choice [1 to 7]: ";       cin >> user_choice;     }          cout << endl;          return 0; } /*************************************************************************   function definitions *************************************************************************/ void showMenu() {     cout << "Choose an option:" << endl              << "1) display the first file line unformatted to screen" << endl              << "2) display the first author name to screen" << endl              << "3) display the first author name, 3 spaces, title count to screen" << endl              << "4) display all authors name, 3 spaces, title count to screen" << endl              << "5) display formatted table of authors no average" << endl              << "6) option 5 plus the formatted average titles per author" << endl              << "7) quit" << endl              << endl;                 return;          } //************************************************************************* void displayFirstAuthorName(const string file_name) {          return; } //************************************************************************* void displayFirstFileLine(const string file_name) {          return; } //************************************************************************* void displayFirstAuthorInformation(const string file_name) {     return; } //************************************************************************* void displayAllAuthorInformation(const string file_name) {          return; } //************************************************************************* void displayFormattedTableNoAverage(const string file_name) {     return; } //************************************************************************* void displayEntireFormattedTable(const string file_name) {          return; } THis is the content of the file, author_titles_data.txt Jane Austen; 6 Charles Dickens; 20 Ernest Hemingway; 9 Jack Kerouac; 22 F. Scott Fitzgerald; 8 Mary Shelley; 7 Charlotte Bronte; 5 Mark Twain; 11 Agatha Christie; 73 Ian Fleming; 14 J.K. Rowling; 14 Stephen King; 54 Oscar Wilde; 1

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
Question

Please use this template

/*************************************************************************
  predefined classes, functions, structures
*************************************************************************/
#include <iostream>        // cin, cout
// missing several
using namespace std;

/*************************************************************************
  global formatting constants
*************************************************************************/
const unsigned int AUTHOR_COLUMN_WIDTH = 25;
const unsigned int TITLE_COUNT_COLUMN_WIDTH = 18;

/*************************************************************************
  function prototypes
*************************************************************************/
void showMenu();
void displayFirstFileLine(const string file_name);
void displayFirstAuthorName(const string file_name);
void displayFirstAuthorInformation(const string file_name);
void displayAllAuthorInformation(const string file_name);
void displayFormattedTableNoAverage(const string file_name);
void displayEntireFormattedTable(const string file_name);

/*************************************************************************
  main() definition
*************************************************************************/


/*************************************************************************
  main() definition
*************************************************************************/
int main()
{    
    // loop through menu
    unsigned int user_choice;
    const string FILE_NAME = "author_titles_data.txt";
    
    // get first user choice
    showMenu();
    
    cout << "Enter your choice [1 to 7]: ";
    cin >> user_choice;
    while (user_choice < 7)
    {
        cout << endl;
        
        switch (user_choice)
        {
            case 1:
                displayFirstFileLine(FILE_NAME);
                break;
            case 2:
                displayFirstAuthorName(FILE_NAME);
                break;
            case 3:
                displayFirstAuthorInformation(FILE_NAME);
                break;
            case 4:
                displayAllAuthorInformation(FILE_NAME);
                break;
            case 5:
                displayFormattedTableNoAverage(FILE_NAME);
                break;
            case 6:
                displayEntireFormattedTable(FILE_NAME);
                break;
            default:
                // nothing
                break;
        }
        
      cout << endl;

      // get next user choice
      showMenu();
      cout << "Enter your choice [1 to 7]: ";
      cin >> user_choice;
    }
    
    cout << endl;
    
    return 0;
}

/*************************************************************************
  function definitions
*************************************************************************/
void showMenu()
{
    cout << "Choose an option:" << endl
             << "1) display the first file line unformatted to screen" << endl
             << "2) display the first author name to screen" << endl
             << "3) display the first author name, 3 spaces, title count to screen" << endl
             << "4) display all authors name, 3 spaces, title count to screen" << endl
             << "5) display formatted table of authors no average" << endl
             << "6) option 5 plus the formatted average titles per author" << endl
             << "7) quit" << endl
             << endl;
             
  return;         
}

//*************************************************************************

void displayFirstAuthorName(const string file_name)
{
    
    return;
}

//*************************************************************************

void displayFirstFileLine(const string file_name)
{
    
    return;
}

//*************************************************************************

void displayFirstAuthorInformation(const string file_name)
{

    return;
}

//*************************************************************************

void displayAllAuthorInformation(const string file_name)
{
    
    return;
}

//*************************************************************************

void displayFormattedTableNoAverage(const string file_name)
{
    return;
}

//*************************************************************************

void displayEntireFormattedTable(const string file_name)
{
    
    return;
}

THis is the content of the file, author_titles_data.txt
Jane Austen; 6
Charles Dickens; 20
Ernest Hemingway; 9
Jack Kerouac; 22
F. Scott Fitzgerald; 8
Mary Shelley; 7
Charlotte Bronte; 5
Mark Twain; 11
Agatha Christie; 73
Ian Fleming; 14
J.K. Rowling; 14
Stephen King; 54
Oscar Wilde; 1

The program will get its data from the input file authorn Vedatatet. This file can be accessed from your lab program. It can also be
downloaded so you can review its contents.
The file contains many lines of information about book authors. Each line is formatted as an author's full name, samicolon, and the number
of books the author has written
John F. Kennedy; 12
Your program will read the file into a program, manipulate the data, and create a formatted table from the data and a calculation
The template gives you a start of the program. There are several new concepts in this template.
The menu illustrates the progression that a programmer develops a complicated program like this. It lets you create this program in
steps and test each step
It is very occasionally a good idea to create global constants. The formatting constants will be used in multiple functions in this
program somaking them global is a good idea.
The albemate way of creating programmer defined functions in C++ appears for the first time this semester. The function prototypes
appear before the definition of main. The function definitions then appear after main(). You'll leam much more about this in CSP
Develop your program in p
(1) Read the first line of the file and redisplay it to the output window
(2) Figure out how to get the full name from the first line of the file. Display the full name to the output window. You'll probably copy and
past the code from step (1) into this function as your starting point.
(3) Figure out how to get the number of books from the first line of the file AS AN INTEGER (HINT: will be useful.) Display the first author's
information in the minimal format from the menu.
(4) Repeat step (3) for every line of the input file
Charlotte Bronte 5
Mark Twain
11
Agatha Christie 73
Ian Fleming
14
3.K. Rowling 14
(5) Now formally format the table. There will be a leff justified title line. The column widths are defined by the global constants. The name
column is left-justified and the number of books column is right-justified. The two columns are separated by a single vertical line character
Ex
Number of Novels Authored
Author N
Jane Austen
Charles Dickens
Ernest Hemingway
Jack Kerouac
Number of Titles
6
22
(6) The last feature is to determine the integer average number of books per author in the file. Display the fully formatted table from step (5)
along with two more lines at the bottom
Ex
Average titles
One more thing. Your program must work for any data file that has the same format as authorsnedatatet Your solution must not depend
on any of the specifics of this particular version of this file, like its number of lines or the total of all the titles
18
Transcribed Image Text:The program will get its data from the input file authorn Vedatatet. This file can be accessed from your lab program. It can also be downloaded so you can review its contents. The file contains many lines of information about book authors. Each line is formatted as an author's full name, samicolon, and the number of books the author has written John F. Kennedy; 12 Your program will read the file into a program, manipulate the data, and create a formatted table from the data and a calculation The template gives you a start of the program. There are several new concepts in this template. The menu illustrates the progression that a programmer develops a complicated program like this. It lets you create this program in steps and test each step It is very occasionally a good idea to create global constants. The formatting constants will be used in multiple functions in this program somaking them global is a good idea. The albemate way of creating programmer defined functions in C++ appears for the first time this semester. The function prototypes appear before the definition of main. The function definitions then appear after main(). You'll leam much more about this in CSP Develop your program in p (1) Read the first line of the file and redisplay it to the output window (2) Figure out how to get the full name from the first line of the file. Display the full name to the output window. You'll probably copy and past the code from step (1) into this function as your starting point. (3) Figure out how to get the number of books from the first line of the file AS AN INTEGER (HINT: will be useful.) Display the first author's information in the minimal format from the menu. (4) Repeat step (3) for every line of the input file Charlotte Bronte 5 Mark Twain 11 Agatha Christie 73 Ian Fleming 14 3.K. Rowling 14 (5) Now formally format the table. There will be a leff justified title line. The column widths are defined by the global constants. The name column is left-justified and the number of books column is right-justified. The two columns are separated by a single vertical line character Ex Number of Novels Authored Author N Jane Austen Charles Dickens Ernest Hemingway Jack Kerouac Number of Titles 6 22 (6) The last feature is to determine the integer average number of books per author in the file. Display the fully formatted table from step (5) along with two more lines at the bottom Ex Average titles One more thing. Your program must work for any data file that has the same format as authorsnedatatet Your solution must not depend on any of the specifics of this particular version of this file, like its number of lines or the total of all the titles 18
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
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.
Similar questions
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