Question

In: Computer Science

use c++ (5) Output the information in a formatted table. The title is right justified with...

use c++

(5) 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. (3 pts)

Ex:

        Number of Novels Authored
Author name         |       Number of novels
--------------------------------------------
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 Flemming        |                     14
J.K. Rowling        |                     14
Stephen King        |                     54
Oscar Wilde         |                      1

Solutions

Expert Solution

CODE:

#include<iostream>
#include<iomanip>

using namespace std;

//main method
int main(){
//array of authors
string author[] = {"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"};
//array of novels
int novels[] = {6,20,9,22,8,7,5,11,73,14,14,54,1};
//printing the title width 33 right justified
cout<<setw(33)<<right<<"Number of Novels Authored"<<endl;
//Columns: Column 1 width: 20, left justified you can change it as per your requirement
//Column 2 width: 23, right justified, divider line width 5 right justified
cout<<setw(20)<<left<<"Author Name"<<setw(5)<<right<<"|"<<setw(23)<<"Number of novels"<<endl;
cout<<setw(20)<<left<<"------------------------"<<setw(23)<<"------------------------"<<endl;
for(int i=0;i<13;i++){
//printing the lines
cout<<setw(20)<<left<<author[i]<<setw(5)<<right<<"|"<<setw(23)<<novels[i]<<endl;
}
return 0;
}

_______________________________________

CODE IMAGES:

________________________________________

OUTPUT:

___________________________________________

Feel free to ask any questions in the comments section

Thank You!


Related Solutions

use C++ (6) Output the information as a formatted histogram. Each name is right justified with...
use C++ (6) Output the information as a formatted histogram. Each name is right justified with a setw() value of 20. (4 pts) 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 *
use c++ (1) Prompt the user for a title for data. Output the title. (1 pt)...
use c++ (1) Prompt the user for a title for data. Output the title. (1 pt) 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. (1 pt) 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) Prompt the...
5.11 LAB: Drawing a right triangle c++ This program will output a right triangle based on...
5.11 LAB: Drawing a right triangle c++ This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as...
Use the data in the table below to complete parts (a) through (c). X: 5 5...
Use the data in the table below to complete parts (a) through (c). X: 5 5 6 9 13 16 18 48 Y: 30 27 18 23 25 20 21 10 A.) Construct a scatterplot of the data. B.) Indentify any possible outliners. A.) The point (18,21) may be an outliner. B.) The point (48,10) may be an outliner C.) The point (5,27) may be an outliner. D.) The point (5,30) may be an outliner E.) There are no outliners....
c# code working but output not right, I need to output all numbers like : Prime...
c# code working but output not right, I need to output all numbers like : Prime factors of 4 are: 2 x 2 here is just 2 Prime factors of 7 are: 7 Prime factors of 30 are: 2 x 3 x 5 Prime factors of 40 are: 2 x 2 x 2 x 5 here is just 2,5 Prime factors of 50 are: 2 x 5 x 5 here is just 2,5 1) How I can fix it 2)I...
When do we use in probability: -the area to the right of Z (when to use right Z-table) -the area to the left (when to use left Z-table)
When do we use in probability: -the area to the right of Z (when to use right Z-table) -the area to the left (when to use left Z-table) -and when do you subtract 1 from the area to the left instead of using the right table ?  
Use SPSS to get the appropriate output. Along with providing the SPSS output, use the 5...
Use SPSS to get the appropriate output. Along with providing the SPSS output, use the 5 steps of hypothesis testing to analyze the results by using the p-value approach. 4. Workers went through a training program to help them in the packaging of items needed for the purchaser to assemble a toy. The number of defective packages returned per month is recorded for each employee doing the packaging. Below are the before and after number of defects per month per...
Use the information in the table above for the following 5 questions. A capital investment project...
Use the information in the table above for the following 5 questions. A capital investment project is estimated to have the following after-tax cash flows, by year: 0 1 2 3 4 -$30,000 $7,500 $12,500 $5,000 $15,000 The company utilizes a discount rate of 10% to evaluate capital projects. You may have rounding errors in your calculations so choose the closest answer.  Assume cash flows occur evenly over the year.    The PAYBACK for the project shown above is: 2.16 3.33 3.15...
Use the information in the table below for the following 5 questions. A capital investment project...
Use the information in the table below for the following 5 questions. A capital investment project is estimated to have the following after-tax cash flows, by year: 0 1 2 3 4 -$50,000 $15,000 $17,500 $17,500 $25,000 The company utilizes a discount rate of 20% to evaluate capital projects. You may have rounding errors in your calculations so choose the closest answer. Assume cash flows are received equally over the year. The NET PRESENT VALUE for the project shown above...
Create a Word document and title it “College Expenses”. In the Word document, insert a table with at least 5 rows and 5 columns. Insert>Table.
Assignment 3 – Incorporating a Table into a Document.Create a Word document and title it “College Expenses”. In the Word document, insert a table with at least 5 rows and 5 columns. Insert>Table.Tell me about your college expenses you have by filling this table with subjects and data. Then write two paragraphs telling me about the information you provided in the table. Bold and color table heading.  Example of table:College ExpensesTuitionBooksComputer/InternetOther suppliesScience ClassMath classC.I.S. ClassEnglish ClassGive the page a proper title....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT