Question: Write a C++ code to implement a software for grocery store with 2 functions. Add Item Sale It is required to save data in structure

Write a C++ code to implement a software for grocery store with 2 functions.

Add Item

Sale

It is required to save data in structure with at least 4 members.

itemCode (5 digit)

itemName

quantity

price

Use file handling to save data of all products.

open file in append mode as used in following example code. If you drop the code in red color then each time a new file will be created and with code in red color same file will loaded and text will be appended at the end of file.

///////////////////////////////////////////////////////////

#include // std::ofstream

int main () {

std::ofstream ofs;

ofs.open ("test.txt", std::ofstream::out | std::ofstream::app);

ofs << " more lines";

ofs.close();

return 0;

}

////////////////////////////////////////////////////////////

Recall the lecture in which we discussed implementation of menu printing using switch-case statement in while loop. So, you must display a menu with three options

Add Item.

Sale

Quit

On selection of Add Item option, user must be prompted to add data of item which is then saved to file.

On selection of sale user must be given two options.

Code

Print

On selection of Code, user must be prompted to input code of item and on selection of Print, stop asking for options from Code and Print and Print the final cash memo with total price.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!