Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ please! 7.21 LAB*: Program: Data visualization (Streams and Functions) Rewrite LAB*: Program: Data visualization (Streams) using functions. 1. Define and declare the getHeader

In C++ please!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

7.21 LAB*: Program: Data visualization (Streams and Functions) Rewrite LAB*: Program: Data visualization (Streams) using functions. 1. Define and declare the getHeader function to match with its calling statement: getHeader (dataTitle, column Headerl, column Header2); 2. Read and understand the createAuthorDataFile function createAuthorDataFile("novels.txt"); 3. Define, declare, and call a function to make table and output data onto table. Give it a meaningful name. 4. Define, declare, and call a function to make histogram. Give it a meaningful name. See below the Data visualization (Streams) Lab instructions: (1) Prompt the user for a title for data. Output the title. Ex: Enter a title for the data: Number of Novels Authored You entered: Number of Novels Authored (2) Prompt the user for the headers of two columns of a table. Output the column headers. Ex: Enter the column 1 header: Author name You entered: Author name Enter the column 2 header: Number of novels You entered: Number of novels (3) Open an output file named "novels.txt". Prompt the user for data points. Data points must be in this format: int string. The user will enter -1 done when they have finished entering data points. Output the data points. Write the data points to an output file. Assume the user enters valid input. Note: this part of the program has already been written and tested. Review the code. Ex: Enter a data point (-1 done to stop input): 6 Jane Austen Data string: Jane Austen Data integer: 6 (4) Close the output file. (5) Open an input file named novels.txt. Now you are using the same file but this time you are reading data from the file and output the information in a formatted table. The title is right justified with a setw( value of 33. Column 1 has a setw() value of 20. Column 2 has a setw() value of 23 Ex: Number of Novels Authored Author name Number of novels 1 Jane Austen Charles Dickens Ernest Hemingway Jack Kerouac F. Scott Fitzgerald Mary Shelley Charlotte Bronte Mark Twain Agatha Christie Ian Flemming J.K. Rowling Stephen King Oscar Wilde 6 20 9 22 8 7 5 11 73 14 14 54 1 (6) Close the input file. (7) Open the input file named novels.txt again. Now you are reading data from the file and output the information as a formatted histogram (display a line of asterisks to match the number of novels written by each author). Each name is right justified with a setw() value of 20. (8) Close the input file. Ex: kkk Jane Austen Charles Dickens Ernest Hemingway ********* Jack Kerouac F. Scott Fitzgerald ******** Mary Shelley Charlotte Bronte ***** Mark Twain *********** Agatha Christie Ian Flemming J.K. Rowling ** Stephen King Oscar Wilde * ***** 293630.1711880.qx3zay int main() { // Variables // FIXME: What variables are needed in main(? Define them below getHeader(dataTitle, columnHeader1, columnHeader2); create AuthorDataFile("novels.txt"); //FIXME: call the make table function //FIXME: call the make histogram function return 0; } //open outFS and put the user data into the file void create Author DataFile(string fileName) { int numNovels; string authorName; ofstream outFS; outFs.open(fileName); cout > numNovels; cin. ignore(); getline(cin, authorName); while (numNovels != -1 && authorName != "done") { // to stop enter -1 done // display data to screen cout > numNovels; 60 cin.ignore(); 61 getline(cin, authorName); 62 } 63 outfs.close(); 64 cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions