Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions