Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C++ PLease!!! I don't know how to fix my mistakes 6.13 LAB*: Program: Data visualization (Streams) (1) Prompt the user for a title for

IN C++ PLease!!! I don't know how to fix my mistakesimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

6.13 LAB*: Program: Data visualization (Streams) (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 6 20 9 22 8 7 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 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: ***** (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: ****** ****** 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 main.cpp Load default template... 1 /* 2 Writing to, reading from data files. 3 Project: Novels 4 5 Name: 6 */ 7 #include 8 #include 9 #include 10 #include 11 #include 12 13 using namespace std; 14 15 int main({ 16 //ariables 17 ofstream outFS; 18 ifstream inFS; main.cpp Load default template... 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 string columnHeader1; string columnHeader2; string authorName; int numNovels; string line; //Get title data cout > numNovels; //Number of novels cin.ignore(); //Skip over one charater getline(cin, authorName); //Get the rest of the line, author's full name 49 59 51 while(numNovels != -1 && authorName != "done"){ //to stop enter -1 done //display data to screen cout > numNovels; cin. ignore(); getline(cin, authorName); } outFS.close(; cout > numNovels; getline(s, authorName); //Prints them to screen cout > numNovels; getline(s, authorName); //Prints author name 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

More Books

Students also viewed these Databases questions