Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ 2 screenshot of the output required put some comment use the driver program giving to you and do not add anything to main AT&T

C++ 2
screenshot of the output required
put some comment
use the driver program giving to you and do not add anything to main
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
AT&T 2:34 PM 18% Lab04 Lab04revised.pdf Q oward County Community College CMSY Lab 4 50 points (Note: This is considered a challenging lab) urpose: To practice using character and structures and binary files. or this lab, please write a program that uses a structure to store the following inventory data in a file: (2 r each item) 2 x 4 = 6 total points) 1. 2. 3. Item Description Quantity on Hand Wholesale Cost ou must use the driver program below and you should not add anything to main. Just write the code fo 1. addRecord 2. viewRecord 3. changeRecord (10 points) 8 points) (10 points) nput validation for Item Quantity and Cost: (3 X 3-9 points) 1. 2. 3. Must be numerie Must not be negative Must be greater than zero (3 points each) (3 points each) (3 points each) ile specifications: (2 points) ou should provide a test file (with reasonable inventory names) that you have used to test your progran he test file should have at least 5 entries and have an extension of"dat he file should be located in "C:itemp n Exit: (2 Points. NOTE: this requirement is net represented on the sample output below) int to the screen: "Thank you for visiting includeciomanip> include using namespace std struet Inventory char desc [301 int qty double wholeSaleCost: // Function prototypes void addRecord(Estream &) void viewRecord(fstream &) void changeRecord (fstream &): int main) Estream inventoryFile: int choice cout > choice, while (choice 4) // Process the selection. switch (choice) // Choice 1 is to add a record Dashboard Calendar To Do Notifications Inbox AT&T 2:24 PM 2026 Lab04 Lab04revised.pdf a do // Display the menu cout > choice while (choice 4) // Process the selection switch (choice) // Choice 1 is to add a recrd case 1: addRecord (inventoryFile) break: // Choice 2 is to view a record case 2: viewRecord (inventoryFile) break; /I Choice 3 is to change a record case 3: changeRecord (inventoryFile) while (choice4) system ("pause") return 0; Page 2 of 4 Howard County Community College Hints: 1. The backslash is used to separate levels in the Microsoft File System e.g. C:Temp Dog.dat Dashboard Calendar To Do Notifications Inbox AT&T 2:26 PM 2026 Lab04 Lab04revised.pdf a Howard County Community College CMSY-171/2 Hints: 1 The backslash is used to separate levels in the Microsoft File System eg. CHTemp Dog.dat File names in Unix use a forward slash cg. C/Temp/Dogdat Those using Unix must comvert the files names before handing in the file 2 Because C++ uses the backslash as a marker meaning that the next character is a special character(like n means CR+LF-two characters), we must use special notation to get a backslash Note that in UNIX the 'n means only one character entry CR the operating system treats as a CR+LF In C4+ we use two backslashes W to signal the compiler that the next character is a special character an that special character is the backslash So file names in Microsoft look like this Ca Temp Dog dat . You might want to manually delete the inventory filke every time you run your program If you don't delete the inventory file and run your program again, you may start working with a file tha is already in existence as opposed to creating a new file. 4 When coding the input validation, do it sach a way that it can be used by other programs with minimun effort. Note -students have asked: Why was the string class not included? This prevents the use of getline) and substring methods that could have made the code more organized and efficient The purpose was to force the students to process the input line as an array of characters Pape 3 of 4 Dashboard Calendar To Do Notifications Inbox AT&T Lab04 Lab04revised.pdf a Sample Output 2:28 PM 2026 Add a new record Uieu an existi record Change an exist record Exit nter your choice (1-4: 1 nter the followi escription: Blue uantity: 50 etail price:.15 inventory data record uritten to file. Add a new record Uieu an existi record Change an exist record Exit nter your choice (1-4: 1 nter the escription: Penci uantity: 180 etail price:.18 record uritten to file following inventory data: Add a new record Uieu an existi record Change an exist record Exit nter your choice : 3 nter the record nunber of the iten: urrent record contents: escription: Blue Pen uantity: 58 etail price: 8.15 nter the new data: escription: Red Pen uantity: 75 Retail price: .20 Add a new record Uieu an existi record Change an exist record Exit nter your choice 1-4: 2 nter the record nunber of the iten: escription: Red Pen uantity: ?5 etail price: 8.20 Dashboard Calendar To Do Notifications Inbox AT&T 2:28 PM 2026 Lab04 Lab04revised.pdf a Enter your choice 1-4: 3 nter the record nunber of the iten: 0 urrent record contents: escription:Blue Pen uantity: 50 Retail price: 8.15 nter the new data: escription: Red Pen uantity: 75 Retail price: .2 . Add a new record Uiew an existing record . Change an existing record 4. Exit Enter your choice 1-4: 2 Enter the record nunber of the iten: 8 escription: Red Pen uantity: 75 Retail price: 8.28 . Add a new record . Uiew an existing record .Change an existing record 4. Exit Enter your choice (1-4): 2 nter the record nunber of the iten: 1 escription: Pencil uantity: 188 Retail price: 8.18 . Add a new record Uiew an existing record Change an existing record Exit nter your choice 1-4 4 Press any key to continue . Page 4 Dashboard Calendar To Do Notifications Inbox

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions

Question

3 1 2 2 x (1,1,2) 3

Answered: 1 week ago