Page 1 of 1

please don't copy I need a new code In this lab, we will practice using various C++ functions to read different types of

Posted: Tue Jul 12, 2022 8:10 am
by answerhappygod
please don't copy I need a new code
In this lab, we will practice using various C++ functions toread different types of data from a data file.
The functions we have discussed include:
Refer to the lecture notes for more details of thesefunctions.
First, take a look at the content of the data file. The datafile is of this format:
The Finkler Question <-- title of a book, also the beginningof the first book record Howard Jacobson <-- author of thebook
3 stars <-- reader star rating
10 12 2010 <-- publication date of the book
15.00 new <-- price of the book
Come, thou Tortoise <-- beginning of the second book
Jessica Grant
4.8 stars
3 9 2012 <-- end of the second book
22.0 mint
...
Your program will read ONLY the following information of eachbook from this data file:
As soon as the program read the appropriate information for onebook, display it on the screen. Then move on to read theinformation of the next book. The information of all the books aredisplayed in the table form. Do not store the information in anykind of data structure for this lab.
Your program will also keep count of the total number of booksread.
Here is an example output of the program:
Please Don T Copy I Need A New Code In This Lab We Will Practice Using Various C Functions To Read Different Types Of 1
Please Don T Copy I Need A New Code In This Lab We Will Practice Using Various C Functions To Read Different Types Of 1 (13.62 KiB) Viewed 59 times
document and input
Please Don T Copy I Need A New Code In This Lab We Will Practice Using Various C Functions To Read Different Types Of 2
Please Don T Copy I Need A New Code In This Lab We Will Practice Using Various C Functions To Read Different Types Of 2 (508.51 KiB) Viewed 59 times
Please Don T Copy I Need A New Code In This Lab We Will Practice Using Various C Functions To Read Different Types Of 3
Please Don T Copy I Need A New Code In This Lab We Will Practice Using Various C Functions To Read Different Types Of 3 (137.56 KiB) Viewed 59 times
#include <iostream>#include <fstream>#include <cassert>#include <iomanip>using namespace std;
void DisplayTableHeading();int main() { int year; string title; string author; float rating; float price; int count=0;
ifstream myIn("library.dat"); assert(myIn);
// Display the heading of thetable DisplayTableHeading();
// Write a while loop here to readinformation for one book at a time // Once a record is read, it calls function"DisplayOneLine" to display the information in the requiredformat
myIn.close();
return 0;}
// Description: This function prints the heading of the outputtable of informationvoid DisplayTableHeading(){ cout << left; cout << fixed << showpoint <<setprecision(2); cout << setw(25) << "TITLE" <<setw(25) << "AUTHOR" << "\t" << "RATING" <<"\t" << "PRICE" << "\t" << "YEAR"<< endl<< endl; return;}
// Description: This function prints one line of information forone bookvoid DisplayOneLine(string title, string author, float rating,float price, int year){ cout << setw(25) << title <<setw(25) << author << "\t" << rating <<"\t" << price << "\t" << year<< endl; return;}
please follow these instructions
Comments have been added to each group of logically relatedstatements, including each:
• Decision statement
• Loop statement
• Group of logically related statement
• User defined function
Variable:
• Meaningful names are used unless specified by the programdescription
• Variable naming convention is followed
• No global variable is used
Constants:
• Defined when appropriate
• Defined in the global declaration section
• Constant naming convention is followed
User defined functions:
• Defined when appropriate
• No function should have more than 25 lines of code (excludewhite lines and lines only containing curly brackets)
• Function naming convention is followed
Proper Indentation is used to make the program easier toread.
• All the decision statements are indented properly.
• All the loop statements are indented properly
• Body of the functions are indented
Blank lines are used in front of each block of logically relatedstatements
Program solves the assigned problem using methods described inprogram description.
Program compiles without errors.
Program executes without crashing.
Program produces the correct output when tested using differentuser input.
Here is an example output of the program: TITLE The Finkler Question: Come, thou Tortoise Catching Fire Mokingjay Winnie's War AUTHOR Howard Jacobson Jessica Grant Suzanne Collins Suzanne Collins Jackson Moss Deente Judy Blume Only One Year Andrea Cheng Can Adults Become Human? Jim Benton There are a total of 8 books. RATING PRICE YEAR 3.00 15.08 2010 4.80 22.00 2012 5.00 9.98 2013 4.60 9.95 2014 3.88 10.58 2013 3.80 0.95 1994 4.90 3.56 1969 4.28 5.35 2886
< library.dat x 1 The Finkler Question 2 Howard Jacobson 3 stars 10 12 2010 15.00 new Come, thou Tortoise Jessica Grant 23 45 6 7 8 9 4.2 stars 3 9 2012 22.0 used 10 11 12 13 14 15 16 17 18 2.9 stars 19 5 7 2014 20 9.95 new 21 Winnie's War 22 Jackson Moss Catching Fire Suzanne Collins 4.9 stars 4 8 2013 9.98 mint Mokingjay Suzanne Collins
library.dat x 21 Winnie's War Jackson Moss 7232 22 23 4.1 stars 9 4 2013 10.50 new 24 25 26 Deenie 27 28 29 30 31 32 33 34 35 Judy Blume 3.3 stars 4 6 1994 0.95 mint Only One Year Andrea Cheng 3.8 stars 9 1 1969 3.56 new Can Adults Become Human? Jim Benton 36 37 38 3.5 stars 39 5 1 2006 40 5.35 mint