SlideShare a Scribd company logo
1 of 16
Download to read offline
You are to write a C++ program to produce an inventory report for a local company. Your input
will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE
ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which
columns the input will be in:
item name item number quantity price safe stock
20 chars 5 char 3 char 6 chars 3 chars
Output will be as follows:
item number item name quantity price price*quantity %ofStock flag
You will put a symbol in the flag field when the inventory quantity is less than the safe stock
value.
This tells the company that they are getting too low on this item and need to build up the stock.
Print the report in sorted ordered, sorted on item number.
Indicate the total value of the stock.
Indicate the percentage of total inventory value to the total value of the highest single item in
inventory. Print the item and its information. (Print this item again at the end of the table.)
You must use the struct data structure and functions.
Use ‘typedef’ for array declarations.
Your input file will be found in invt.txt.
invt.txt looks like this:
Wong Batts 98723 243 6.45 200
Widgets No Two 83209 970 17.50 800
HumpBack Whale Songs 74329 42 23.70 50
Frozen Ice Cubes 73922 100 0.15 250
Plastic Ice Cubes 10044 450 0.60 540
Canned Solar Winds 23923 12 550.00 5
Sented Toe Jamm 18492 14 0.50 20
UnSented Toe Jam 18499 23 .74 20
Backwards Left Turns 87293 5 34.95 12
El Slick Slider 38324 15 225.00 18
Meals for Up Chuck 62042 20 16.50 24
Super House Cleaner 71083 14 69.85 18
Stars Dancing Shoes 23934 80 22.50 75
LowRider Briches 98744 138 45.95 125
HighRider Shoes 12283 372 35.95 400
Colored Pie Charts 51121 60 1.50 30
LensLess Saftey Glas 44433 22 2.10 35
Used Boat Anchors 73277 6 17.50 7
You are to write a C++ program to produce an inventory report for a local company. Your input
will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE
ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which
columns the input will be in:
item name item number quantity price safe stock
20 chars 5 char 3 char 6 chars 3 chars
Output will be as follows:
item number item name quantity price price*quantity %ofStock flag
You will put a symbol in the flag field when the inventory quantity is less than the safe stock
value.
This tells the company that they are getting too low on this item and need to build up the stock.
Print the report in sorted ordered, sorted on item number.
Indicate the total value of the stock.
Indicate the percentage of total inventory value to the total value of the highest single item in
inventory. Print the item and its information. (Print this item again at the end of the table.)
You must use the struct data structure and functions.
Use ‘typedef’ for array declarations.
Your input file will be found in invt.txt.
invt.txt looks like this:
Wong Batts 98723 243 6.45 200
Widgets No Two 83209 970 17.50 800
HumpBack Whale Songs 74329 42 23.70 50
Frozen Ice Cubes 73922 100 0.15 250
Plastic Ice Cubes 10044 450 0.60 540
Canned Solar Winds 23923 12 550.00 5
Sented Toe Jamm 18492 14 0.50 20
UnSented Toe Jam 18499 23 .74 20
Backwards Left Turns 87293 5 34.95 12
El Slick Slider 38324 15 225.00 18
Meals for Up Chuck 62042 20 16.50 24
Super House Cleaner 71083 14 69.85 18
Stars Dancing Shoes 23934 80 22.50 75
LowRider Briches 98744 138 45.95 125
HighRider Shoes 12283 372 35.95 400
Colored Pie Charts 51121 60 1.50 30
LensLess Saftey Glas 44433 22 2.10 35
Used Boat Anchors 73277 6 17.50 7
You are to write a C++ program to produce an inventory report for a local company. Your input
will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE
ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which
columns the input will be in:
item name item number quantity price safe stock
20 chars 5 char 3 char 6 chars 3 chars
Output will be as follows:
item number item name quantity price price*quantity %ofStock flag
You will put a symbol in the flag field when the inventory quantity is less than the safe stock
value.
This tells the company that they are getting too low on this item and need to build up the stock.
Print the report in sorted ordered, sorted on item number.
Indicate the total value of the stock.
Indicate the percentage of total inventory value to the total value of the highest single item in
inventory. Print the item and its information. (Print this item again at the end of the table.)
You must use the struct data structure and functions.
Use ‘typedef’ for array declarations.
Your input file will be found in invt.txt.
invt.txt looks like this:
Wong Batts 98723 243 6.45 200
Widgets No Two 83209 970 17.50 800
HumpBack Whale Songs 74329 42 23.70 50
Frozen Ice Cubes 73922 100 0.15 250
Plastic Ice Cubes 10044 450 0.60 540
Canned Solar Winds 23923 12 550.00 5
Sented Toe Jamm 18492 14 0.50 20
UnSented Toe Jam 18499 23 .74 20
Backwards Left Turns 87293 5 34.95 12
El Slick Slider 38324 15 225.00 18
Meals for Up Chuck 62042 20 16.50 24
Super House Cleaner 71083 14 69.85 18
Stars Dancing Shoes 23934 80 22.50 75
LowRider Briches 98744 138 45.95 125
HighRider Shoes 12283 372 35.95 400
Colored Pie Charts 51121 60 1.50 30
LensLess Saftey Glas 44433 22 2.10 35
Used Boat Anchors 73277 6 17.50 7
You are to write a C++ program to produce an inventory report for a local company. Your input
will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE
ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which
columns the input will be in:
item name item number quantity price safe stock
20 chars 5 char 3 char 6 chars 3 chars
Output will be as follows:
item number item name quantity price price*quantity %ofStock flag
You will put a symbol in the flag field when the inventory quantity is less than the safe stock
value.
This tells the company that they are getting too low on this item and need to build up the stock.
Print the report in sorted ordered, sorted on item number.
Indicate the total value of the stock.
Indicate the percentage of total inventory value to the total value of the highest single item in
inventory. Print the item and its information. (Print this item again at the end of the table.)
You must use the struct data structure and functions.
Use ‘typedef’ for array declarations.
Your input file will be found in invt.txt.
invt.txt looks like this:
Wong Batts 98723 243 6.45 200
Widgets No Two 83209 970 17.50 800
HumpBack Whale Songs 74329 42 23.70 50
Frozen Ice Cubes 73922 100 0.15 250
Plastic Ice Cubes 10044 450 0.60 540
Canned Solar Winds 23923 12 550.00 5
Sented Toe Jamm 18492 14 0.50 20
UnSented Toe Jam 18499 23 .74 20
Backwards Left Turns 87293 5 34.95 12
El Slick Slider 38324 15 225.00 18
Meals for Up Chuck 62042 20 16.50 24
Super House Cleaner 71083 14 69.85 18
Stars Dancing Shoes 23934 80 22.50 75
LowRider Briches 98744 138 45.95 125
HighRider Shoes 12283 372 35.95 400
Colored Pie Charts 51121 60 1.50 30
LensLess Saftey Glas 44433 22 2.10 35
Used Boat Anchors 73277 6 17.50 7
You are to write a C++ program to produce an inventory report for a local company. Your input
will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE
ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which
columns the input will be in:
item name item number quantity price safe stock
20 chars 5 char 3 char 6 chars 3 chars
Output will be as follows:
item number item name quantity price price*quantity %ofStock flag
You will put a symbol in the flag field when the inventory quantity is less than the safe stock
value.
This tells the company that they are getting too low on this item and need to build up the stock.
Print the report in sorted ordered, sorted on item number.
Indicate the total value of the stock.
Indicate the percentage of total inventory value to the total value of the highest single item in
inventory. Print the item and its information. (Print this item again at the end of the table.)
You must use the struct data structure and functions.
Use ‘typedef’ for array declarations.
Your input file will be found in invt.txt.
invt.txt looks like this:
Wong Batts 98723 243 6.45 200
Widgets No Two 83209 970 17.50 800
HumpBack Whale Songs 74329 42 23.70 50
Frozen Ice Cubes 73922 100 0.15 250
Plastic Ice Cubes 10044 450 0.60 540
Canned Solar Winds 23923 12 550.00 5
Sented Toe Jamm 18492 14 0.50 20
UnSented Toe Jam 18499 23 .74 20
Backwards Left Turns 87293 5 34.95 12
El Slick Slider 38324 15 225.00 18
Meals for Up Chuck 62042 20 16.50 24
Super House Cleaner 71083 14 69.85 18
Stars Dancing Shoes 23934 80 22.50 75
LowRider Briches 98744 138 45.95 125
HighRider Shoes 12283 372 35.95 400
Colored Pie Charts 51121 60 1.50 30
LensLess Saftey Glas 44433 22 2.10 35
Used Boat Anchors 73277 6 17.50 7
Wong Batts 98723 243 6.45 200
Widgets No Two 83209 970 17.50 800
HumpBack Whale Songs 74329 42 23.70 50
Frozen Ice Cubes 73922 100 0.15 250
Plastic Ice Cubes 10044 450 0.60 540
Canned Solar Winds 23923 12 550.00 5
Sented Toe Jamm 18492 14 0.50 20
UnSented Toe Jam 18499 23 .74 20
Backwards Left Turns 87293 5 34.95 12
El Slick Slider 38324 15 225.00 18
Meals for Up Chuck 62042 20 16.50 24
Super House Cleaner 71083 14 69.85 18
Stars Dancing Shoes 23934 80 22.50 75
LowRider Briches 98744 138 45.95 125
HighRider Shoes 12283 372 35.95 400
Colored Pie Charts 51121 60 1.50 30
LensLess Saftey Glas 44433 22 2.10 35
Used Boat Anchors 73277 6 17.50 7
Solution
#include
#include
#include
#include
#include
#include
using namespace std;
// define a data structure
struct InventoryRecord
{
string name; // inventory item name
int qty; // how many are in stock
double cost; // the cost
};
// const for the max size of the record array
const int MAX_SIZE = 9;
// function prototypes
void addData(InventoryRecord list[], int& size);
void dispData(const InventoryRecord list[], int size);
void saveFile(const InventoryRecord list[], int size);
void openFile(InventoryRecord list[], int& size);
char getMenuResponse();
int main(int argc, char *argv[])
{
InventoryRecord recList[MAX_SIZE];
int numOfRecs = 0;
bool run = true;
do
{
cout << "Inventory Program - " << numOfRecs << " items in stock" << endl;
switch ( getMenuResponse() )
{
case 'A': addData(recList, numOfRecs); break;
case 'D': dispData(recList, numOfRecs); break;
case 'O': openFile(recList, numOfRecs); break;
case 'S': saveFile(recList, numOfRecs); break;
case 'Q': run = false; break;
default : cout << "That is NOT a valid choice" << endl;
}
} while (run);
cout << endl << "Program Terminated" << endl;
// system("PAUSE"); // Program exits immediatly upon "Quit" if commented out
return EXIT_SUCCESS;
}
// Task: Allow data entry of one inventory item
// Accepts: References to the inventory array and its size
// Returns: Nothing
// Modifies: The array and size 'actual parameter'
// NOTE: Could be modified to allow entry of more than one item
void addData(InventoryRecord list[], int& size)
{
InventoryRecord tmp; // declare a temp item that we will load before putting in the array
char response;
char str[256]; // needed for cin.getline; we are going to use a char array
if (size < MAX_SIZE) {
system("cls");
cout << "Enter Inventory Records" << endl << endl;
cout << "Name: ";
// Get up to 256 characters from the keyboard including white space.
// Stop reading if encounter the  first. If there's any chance of
// more than 256 characters you will have to clean up cin with
// cin.ignore before the next input.
cin.getline(str, 256, ' '); // for char arrays; different from the other getline
tmp.name = str;
cout << "Quantity: ";
cin >> tmp.qty;
cout << "Cost: ";
cin >> tmp.cost;
cout << endl;
// see if this record should be added to the array
cout << "Add the record to inventory? (y/n) ";
cin >> response;
if (toupper(response) == 'Y')
list[size++] = tmp;
} else {
cout << "Inventory at full; cannot enter more unit." << endl;
system("pause");
}
system("cls");
}
void dispData(const InventoryRecord list[], int size)
{
system("cls");
double cost = 0;
if(size < 1) {
cout << "Nothing to display" << endl;
} else {
cout << "All Inventory item has been shown" << endl << endl;
cout << fixed << setprecision(2);
cout << "Item Name Qty Cost" << endl;
cout << "~~~~~~~~~~~~~~~~~~" << endl;
cout << left;
for (int i = 0; i < size; i++) {
cout << setw(21) << list[i].name << right
<< setw(4) << list[i].qty
<< setw(10) << list[i].cost << left << endl;
cost = cost + list[i].cost * list[i].qty;
}
cout << "~~~~~~~~~~~~~~~~~~~" << endl;
cout << right << setw(3) << size;
cout << " items listed";
cout << right << setw(19) << cost << endl << endl;
}
system("PAUSE");
system("cls");
}
// Save records to disc
void saveFile(const InventoryRecord list[], int size) {
ofstream outfi("Inventory.txt");
// make sure the file stream is open before doing IO
if (!outfi.fail()) {
system("cls");
cout << "Saving inventory to the disc ";
for(int i = 0; i < size; i++) {
outfi << list[i].name << ';'
<< list[i].qty << ';'
<< list[i].cost;
// Start a new line after all but the last record
// Simplifies reading the file as EOF is at end of last line
if (i < size-1) outfi << endl;
}
cout << endl << size << " records writen to the disc." << endl;
outfi.close();
system("PAUSE");
system("cls");
}
else {
cout << "ERROR: problem with file" << endl;
system("PAUSE");
system("cls");
}
}
// Open file and load array
void openFile(InventoryRecord list[], int& size)
{
ifstream infi("Inventory.txt");
string str;
stringstream strstrm;
// make sure the file stream is open before doing IO
if (!infi.fail()) {
system("cls");
cout << "Reading inventory from the disc ";
size = 0; // overwrite any existing records
while(!infi.eof() && size < MAX_SIZE) {
// get and store the name
getline(infi, str, ';');
list[size].name = str;
// get, convert and store the quantity
getline(infi, str, ';');
strstrm.str(""); strstrm.clear(); // empty and clear the stringstream
strstrm << str;
strstrm >> list[size].qty;
// get, convert and store the cost
getline(infi, str);
strstrm.str(""); strstrm.clear(); // empty and clear the stringstream
strstrm << str;
strstrm >> list[size++].cost;
}
cout << endl << size << " records read from the disc." << endl;
system("PAUSE");
system("cls");
}
else { // something went wrong with opening the file
cout << "ERROR: problem with file" << endl;
system("PAUSE");
system("cls");
}
}
char getMenuResponse()
{
char response;
cout << endl << "Make your selection" << endl
<< "(A)dd Record, (D)isplay Records, (O)pen File, (S)ave File, (Q)uit" << endl
<< "> ";
cin >> response;
cin.ignore(256, ' ');
}

More Related Content

Similar to You are to write a C++ program to produce an inventory repor.pdf

Below is my code- I have an error that I still have difficulty figurin.pdf
Below is my code- I have an error that I still have difficulty figurin.pdfBelow is my code- I have an error that I still have difficulty figurin.pdf
Below is my code- I have an error that I still have difficulty figurin.pdf
armanuelraj
 
Case Study 3 Production Cost Perfect Comp Answer Sheet - new
Case Study 3 Production Cost Perfect Comp Answer Sheet - newCase Study 3 Production Cost Perfect Comp Answer Sheet - new
Case Study 3 Production Cost Perfect Comp Answer Sheet - new
Kayla Davenport
 
Have you ever wonder how Excel sets the upper limit and the lower limit on th...
Have you ever wonder how Excel sets the upper limit and the lower limit on th...Have you ever wonder how Excel sets the upper limit and the lower limit on th...
Have you ever wonder how Excel sets the upper limit and the lower limit on th...
​Jennifer ChiaYu Lin
 
Pre-Calculus Midterm Exam 1 Score ______ ____.docx
Pre-Calculus Midterm Exam  1  Score ______  ____.docxPre-Calculus Midterm Exam  1  Score ______  ____.docx
Pre-Calculus Midterm Exam 1 Score ______ ____.docx
ChantellPantoja184
 

Similar to You are to write a C++ program to produce an inventory repor.pdf (20)

R Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In RR Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In R
 
Xml pres 1
Xml pres 1 Xml pres 1
Xml pres 1
 
Below is my code- I have an error that I still have difficulty figurin.pdf
Below is my code- I have an error that I still have difficulty figurin.pdfBelow is my code- I have an error that I still have difficulty figurin.pdf
Below is my code- I have an error that I still have difficulty figurin.pdf
 
MH prediction modeling and validation in r (1) regression 190709
MH prediction modeling and validation in r (1) regression 190709MH prediction modeling and validation in r (1) regression 190709
MH prediction modeling and validation in r (1) regression 190709
 
Case Study 3 Production Cost Perfect Comp Answer Sheet - new
Case Study 3 Production Cost Perfect Comp Answer Sheet - newCase Study 3 Production Cost Perfect Comp Answer Sheet - new
Case Study 3 Production Cost Perfect Comp Answer Sheet - new
 
Devry bis-155-final-exam-guide
Devry bis-155-final-exam-guideDevry bis-155-final-exam-guide
Devry bis-155-final-exam-guide
 
The Ring programming language version 1.10 book - Part 127 of 212
The Ring programming language version 1.10 book - Part 127 of 212The Ring programming language version 1.10 book - Part 127 of 212
The Ring programming language version 1.10 book - Part 127 of 212
 
A look at the CQL changes in 3.x (Benjamin Lerer, Datastax) | Cassandra Summi...
A look at the CQL changes in 3.x (Benjamin Lerer, Datastax) | Cassandra Summi...A look at the CQL changes in 3.x (Benjamin Lerer, Datastax) | Cassandra Summi...
A look at the CQL changes in 3.x (Benjamin Lerer, Datastax) | Cassandra Summi...
 
A look at the cql changes in 3.x
A look at the cql changes in 3.xA look at the cql changes in 3.x
A look at the cql changes in 3.x
 
Database Management System - SQL Advanced Training
Database Management System - SQL Advanced TrainingDatabase Management System - SQL Advanced Training
Database Management System - SQL Advanced Training
 
Have you ever wonder how Excel sets the upper limit and the lower limit on th...
Have you ever wonder how Excel sets the upper limit and the lower limit on th...Have you ever wonder how Excel sets the upper limit and the lower limit on th...
Have you ever wonder how Excel sets the upper limit and the lower limit on th...
 
Cluto presentation
Cluto presentationCluto presentation
Cluto presentation
 
Arrays
ArraysArrays
Arrays
 
Data cleansing project
Data cleansing project Data cleansing project
Data cleansing project
 
DBMS Lab
DBMS LabDBMS Lab
DBMS Lab
 
Introduction to tibbles
Introduction to tibblesIntroduction to tibbles
Introduction to tibbles
 
Pre-Calculus Midterm Exam 1 Score ______ ____.docx
Pre-Calculus Midterm Exam  1  Score ______  ____.docxPre-Calculus Midterm Exam  1  Score ______  ____.docx
Pre-Calculus Midterm Exam 1 Score ______ ____.docx
 
ABAP Advanced List
ABAP Advanced ListABAP Advanced List
ABAP Advanced List
 
histgram[1].ppt
histgram[1].ppthistgram[1].ppt
histgram[1].ppt
 
4. linear programming using excel solver
4. linear programming using excel solver4. linear programming using excel solver
4. linear programming using excel solver
 

More from udit652068

Did BP respond in a manner that was appropriate with the oil spill t.pdf
Did BP respond in a manner that was appropriate with the oil spill t.pdfDid BP respond in a manner that was appropriate with the oil spill t.pdf
Did BP respond in a manner that was appropriate with the oil spill t.pdf
udit652068
 
Describe and provide at least two examples of direct transmission of.pdf
Describe and provide at least two examples of direct transmission of.pdfDescribe and provide at least two examples of direct transmission of.pdf
Describe and provide at least two examples of direct transmission of.pdf
udit652068
 
Define e-commerce and describe how it differs from e-business.So.pdf
Define e-commerce and describe how it differs from e-business.So.pdfDefine e-commerce and describe how it differs from e-business.So.pdf
Define e-commerce and describe how it differs from e-business.So.pdf
udit652068
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
udit652068
 
Write a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdfWrite a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdf
udit652068
 
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdf
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdfUsing the header(dlist) and mainline file (dlistapp) belowYou are .pdf
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdf
udit652068
 
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdfTOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
udit652068
 
These are the outputs which should match they are 4 of them -outp.pdf
These are the outputs which should match they are 4 of them -outp.pdfThese are the outputs which should match they are 4 of them -outp.pdf
These are the outputs which should match they are 4 of them -outp.pdf
udit652068
 
The selection of officials in which of the following branches of the.pdf
The selection of officials in which of the following branches of the.pdfThe selection of officials in which of the following branches of the.pdf
The selection of officials in which of the following branches of the.pdf
udit652068
 

More from udit652068 (20)

Discuss briefly and with examples, What key measures need to be take.pdf
Discuss briefly and with examples, What key measures need to be take.pdfDiscuss briefly and with examples, What key measures need to be take.pdf
Discuss briefly and with examples, What key measures need to be take.pdf
 
Did BP respond in a manner that was appropriate with the oil spill t.pdf
Did BP respond in a manner that was appropriate with the oil spill t.pdfDid BP respond in a manner that was appropriate with the oil spill t.pdf
Did BP respond in a manner that was appropriate with the oil spill t.pdf
 
Describe and provide at least two examples of direct transmission of.pdf
Describe and provide at least two examples of direct transmission of.pdfDescribe and provide at least two examples of direct transmission of.pdf
Describe and provide at least two examples of direct transmission of.pdf
 
Define VRIO in business strategy Define VRIO in business strat.pdf
Define VRIO in business strategy Define VRIO in business strat.pdfDefine VRIO in business strategy Define VRIO in business strat.pdf
Define VRIO in business strategy Define VRIO in business strat.pdf
 
Define e-commerce and describe how it differs from e-business.So.pdf
Define e-commerce and describe how it differs from e-business.So.pdfDefine e-commerce and describe how it differs from e-business.So.pdf
Define e-commerce and describe how it differs from e-business.So.pdf
 
Building Social Business - EssaySolutionBuilding social busine.pdf
Building Social Business - EssaySolutionBuilding social busine.pdfBuilding Social Business - EssaySolutionBuilding social busine.pdf
Building Social Business - EssaySolutionBuilding social busine.pdf
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
Write a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdfWrite a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdf
 
Which of the following defines a method doubleEach that returns an ar.pdf
Which of the following defines a method doubleEach that returns an ar.pdfWhich of the following defines a method doubleEach that returns an ar.pdf
Which of the following defines a method doubleEach that returns an ar.pdf
 
When the Fed provides more reserves toprovides more reserves to.pdf
When the Fed provides more reserves toprovides more reserves to.pdfWhen the Fed provides more reserves toprovides more reserves to.pdf
When the Fed provides more reserves toprovides more reserves to.pdf
 
What is a common infrastructure and what does it provideSolutio.pdf
What is a common infrastructure and what does it provideSolutio.pdfWhat is a common infrastructure and what does it provideSolutio.pdf
What is a common infrastructure and what does it provideSolutio.pdf
 
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdf
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdfWhat are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdf
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdf
 
What are some of the commonly seen WLAN devices What role does each.pdf
What are some of the commonly seen WLAN devices What role does each.pdfWhat are some of the commonly seen WLAN devices What role does each.pdf
What are some of the commonly seen WLAN devices What role does each.pdf
 
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdf
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdfUsing the header(dlist) and mainline file (dlistapp) belowYou are .pdf
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdf
 
Virology.Explain the make up and role of different complexes for .pdf
Virology.Explain the make up and role of different complexes for .pdfVirology.Explain the make up and role of different complexes for .pdf
Virology.Explain the make up and role of different complexes for .pdf
 
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdfTOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
 
These are the outputs which should match they are 4 of them -outp.pdf
These are the outputs which should match they are 4 of them -outp.pdfThese are the outputs which should match they are 4 of them -outp.pdf
These are the outputs which should match they are 4 of them -outp.pdf
 
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdf
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdfThe test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdf
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdf
 
The selection of officials in which of the following branches of the.pdf
The selection of officials in which of the following branches of the.pdfThe selection of officials in which of the following branches of the.pdf
The selection of officials in which of the following branches of the.pdf
 
the distance between the N-terminal and C-ternimal amino acids varie.pdf
the distance between the N-terminal and C-ternimal amino acids varie.pdfthe distance between the N-terminal and C-ternimal amino acids varie.pdf
the distance between the N-terminal and C-ternimal amino acids varie.pdf
 

Recently uploaded

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

You are to write a C++ program to produce an inventory repor.pdf

  • 1. You are to write a C++ program to produce an inventory report for a local company. Your input will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which columns the input will be in: item name item number quantity price safe stock 20 chars 5 char 3 char 6 chars 3 chars Output will be as follows: item number item name quantity price price*quantity %ofStock flag You will put a symbol in the flag field when the inventory quantity is less than the safe stock value. This tells the company that they are getting too low on this item and need to build up the stock. Print the report in sorted ordered, sorted on item number. Indicate the total value of the stock. Indicate the percentage of total inventory value to the total value of the highest single item in inventory. Print the item and its information. (Print this item again at the end of the table.)
  • 2. You must use the struct data structure and functions. Use ‘typedef’ for array declarations. Your input file will be found in invt.txt. invt.txt looks like this: Wong Batts 98723 243 6.45 200 Widgets No Two 83209 970 17.50 800 HumpBack Whale Songs 74329 42 23.70 50 Frozen Ice Cubes 73922 100 0.15 250 Plastic Ice Cubes 10044 450 0.60 540 Canned Solar Winds 23923 12 550.00 5 Sented Toe Jamm 18492 14 0.50 20 UnSented Toe Jam 18499 23 .74 20 Backwards Left Turns 87293 5 34.95 12 El Slick Slider 38324 15 225.00 18 Meals for Up Chuck 62042 20 16.50 24 Super House Cleaner 71083 14 69.85 18 Stars Dancing Shoes 23934 80 22.50 75 LowRider Briches 98744 138 45.95 125 HighRider Shoes 12283 372 35.95 400 Colored Pie Charts 51121 60 1.50 30 LensLess Saftey Glas 44433 22 2.10 35 Used Boat Anchors 73277 6 17.50 7
  • 3. You are to write a C++ program to produce an inventory report for a local company. Your input will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which columns the input will be in: item name item number quantity price safe stock 20 chars 5 char 3 char 6 chars 3 chars Output will be as follows: item number item name quantity price price*quantity %ofStock flag You will put a symbol in the flag field when the inventory quantity is less than the safe stock value. This tells the company that they are getting too low on this item and need to build up the stock. Print the report in sorted ordered, sorted on item number. Indicate the total value of the stock. Indicate the percentage of total inventory value to the total value of the highest single item in inventory. Print the item and its information. (Print this item again at the end of the table.) You must use the struct data structure and functions. Use ‘typedef’ for array declarations. Your input file will be found in invt.txt.
  • 4. invt.txt looks like this: Wong Batts 98723 243 6.45 200 Widgets No Two 83209 970 17.50 800 HumpBack Whale Songs 74329 42 23.70 50 Frozen Ice Cubes 73922 100 0.15 250 Plastic Ice Cubes 10044 450 0.60 540 Canned Solar Winds 23923 12 550.00 5 Sented Toe Jamm 18492 14 0.50 20 UnSented Toe Jam 18499 23 .74 20 Backwards Left Turns 87293 5 34.95 12 El Slick Slider 38324 15 225.00 18 Meals for Up Chuck 62042 20 16.50 24 Super House Cleaner 71083 14 69.85 18 Stars Dancing Shoes 23934 80 22.50 75 LowRider Briches 98744 138 45.95 125 HighRider Shoes 12283 372 35.95 400 Colored Pie Charts 51121 60 1.50 30 LensLess Saftey Glas 44433 22 2.10 35 Used Boat Anchors 73277 6 17.50 7 You are to write a C++ program to produce an inventory report for a local company. Your input will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which columns the input will be in:
  • 5. item name item number quantity price safe stock 20 chars 5 char 3 char 6 chars 3 chars Output will be as follows: item number item name quantity price price*quantity %ofStock flag You will put a symbol in the flag field when the inventory quantity is less than the safe stock value. This tells the company that they are getting too low on this item and need to build up the stock. Print the report in sorted ordered, sorted on item number. Indicate the total value of the stock. Indicate the percentage of total inventory value to the total value of the highest single item in inventory. Print the item and its information. (Print this item again at the end of the table.) You must use the struct data structure and functions. Use ‘typedef’ for array declarations. Your input file will be found in invt.txt. invt.txt looks like this:
  • 6. Wong Batts 98723 243 6.45 200 Widgets No Two 83209 970 17.50 800 HumpBack Whale Songs 74329 42 23.70 50 Frozen Ice Cubes 73922 100 0.15 250 Plastic Ice Cubes 10044 450 0.60 540 Canned Solar Winds 23923 12 550.00 5 Sented Toe Jamm 18492 14 0.50 20 UnSented Toe Jam 18499 23 .74 20 Backwards Left Turns 87293 5 34.95 12 El Slick Slider 38324 15 225.00 18 Meals for Up Chuck 62042 20 16.50 24 Super House Cleaner 71083 14 69.85 18 Stars Dancing Shoes 23934 80 22.50 75 LowRider Briches 98744 138 45.95 125 HighRider Shoes 12283 372 35.95 400 Colored Pie Charts 51121 60 1.50 30 LensLess Saftey Glas 44433 22 2.10 35 Used Boat Anchors 73277 6 17.50 7 You are to write a C++ program to produce an inventory report for a local company. Your input will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which columns the input will be in: item name item number quantity price safe stock 20 chars 5 char 3 char 6 chars 3 chars Output will be as follows:
  • 7. item number item name quantity price price*quantity %ofStock flag You will put a symbol in the flag field when the inventory quantity is less than the safe stock value. This tells the company that they are getting too low on this item and need to build up the stock. Print the report in sorted ordered, sorted on item number. Indicate the total value of the stock. Indicate the percentage of total inventory value to the total value of the highest single item in inventory. Print the item and its information. (Print this item again at the end of the table.) You must use the struct data structure and functions. Use ‘typedef’ for array declarations. Your input file will be found in invt.txt. invt.txt looks like this: Wong Batts 98723 243 6.45 200 Widgets No Two 83209 970 17.50 800 HumpBack Whale Songs 74329 42 23.70 50 Frozen Ice Cubes 73922 100 0.15 250 Plastic Ice Cubes 10044 450 0.60 540 Canned Solar Winds 23923 12 550.00 5 Sented Toe Jamm 18492 14 0.50 20
  • 8. UnSented Toe Jam 18499 23 .74 20 Backwards Left Turns 87293 5 34.95 12 El Slick Slider 38324 15 225.00 18 Meals for Up Chuck 62042 20 16.50 24 Super House Cleaner 71083 14 69.85 18 Stars Dancing Shoes 23934 80 22.50 75 LowRider Briches 98744 138 45.95 125 HighRider Shoes 12283 372 35.95 400 Colored Pie Charts 51121 60 1.50 30 LensLess Saftey Glas 44433 22 2.10 35 Used Boat Anchors 73277 6 17.50 7 You are to write a C++ program to produce an inventory report for a local company. Your input will be item name, item number, quantity, price per item, safe stock value. YOU ARE TO USE ARRAYS AND FUNCTIONS. The output will be sent to a file. The following shows which columns the input will be in: item name item number quantity price safe stock 20 chars 5 char 3 char 6 chars 3 chars Output will be as follows: item number item name quantity price price*quantity %ofStock flag You will put a symbol in the flag field when the inventory quantity is less than the safe stock
  • 9. value. This tells the company that they are getting too low on this item and need to build up the stock. Print the report in sorted ordered, sorted on item number. Indicate the total value of the stock. Indicate the percentage of total inventory value to the total value of the highest single item in inventory. Print the item and its information. (Print this item again at the end of the table.) You must use the struct data structure and functions. Use ‘typedef’ for array declarations. Your input file will be found in invt.txt. invt.txt looks like this: Wong Batts 98723 243 6.45 200 Widgets No Two 83209 970 17.50 800 HumpBack Whale Songs 74329 42 23.70 50 Frozen Ice Cubes 73922 100 0.15 250 Plastic Ice Cubes 10044 450 0.60 540 Canned Solar Winds 23923 12 550.00 5 Sented Toe Jamm 18492 14 0.50 20 UnSented Toe Jam 18499 23 .74 20 Backwards Left Turns 87293 5 34.95 12 El Slick Slider 38324 15 225.00 18 Meals for Up Chuck 62042 20 16.50 24 Super House Cleaner 71083 14 69.85 18 Stars Dancing Shoes 23934 80 22.50 75 LowRider Briches 98744 138 45.95 125 HighRider Shoes 12283 372 35.95 400
  • 10. Colored Pie Charts 51121 60 1.50 30 LensLess Saftey Glas 44433 22 2.10 35 Used Boat Anchors 73277 6 17.50 7 Wong Batts 98723 243 6.45 200 Widgets No Two 83209 970 17.50 800 HumpBack Whale Songs 74329 42 23.70 50 Frozen Ice Cubes 73922 100 0.15 250 Plastic Ice Cubes 10044 450 0.60 540 Canned Solar Winds 23923 12 550.00 5 Sented Toe Jamm 18492 14 0.50 20 UnSented Toe Jam 18499 23 .74 20 Backwards Left Turns 87293 5 34.95 12 El Slick Slider 38324 15 225.00 18 Meals for Up Chuck 62042 20 16.50 24 Super House Cleaner 71083 14 69.85 18 Stars Dancing Shoes 23934 80 22.50 75 LowRider Briches 98744 138 45.95 125 HighRider Shoes 12283 372 35.95 400 Colored Pie Charts 51121 60 1.50 30 LensLess Saftey Glas 44433 22 2.10 35 Used Boat Anchors 73277 6 17.50 7 Solution #include #include #include #include #include #include using namespace std; // define a data structure
  • 11. struct InventoryRecord { string name; // inventory item name int qty; // how many are in stock double cost; // the cost }; // const for the max size of the record array const int MAX_SIZE = 9; // function prototypes void addData(InventoryRecord list[], int& size); void dispData(const InventoryRecord list[], int size); void saveFile(const InventoryRecord list[], int size); void openFile(InventoryRecord list[], int& size); char getMenuResponse(); int main(int argc, char *argv[]) { InventoryRecord recList[MAX_SIZE]; int numOfRecs = 0; bool run = true; do { cout << "Inventory Program - " << numOfRecs << " items in stock" << endl; switch ( getMenuResponse() ) { case 'A': addData(recList, numOfRecs); break; case 'D': dispData(recList, numOfRecs); break; case 'O': openFile(recList, numOfRecs); break; case 'S': saveFile(recList, numOfRecs); break; case 'Q': run = false; break; default : cout << "That is NOT a valid choice" << endl; } } while (run); cout << endl << "Program Terminated" << endl; // system("PAUSE"); // Program exits immediatly upon "Quit" if commented out
  • 12. return EXIT_SUCCESS; } // Task: Allow data entry of one inventory item // Accepts: References to the inventory array and its size // Returns: Nothing // Modifies: The array and size 'actual parameter' // NOTE: Could be modified to allow entry of more than one item void addData(InventoryRecord list[], int& size) { InventoryRecord tmp; // declare a temp item that we will load before putting in the array char response; char str[256]; // needed for cin.getline; we are going to use a char array if (size < MAX_SIZE) { system("cls"); cout << "Enter Inventory Records" << endl << endl; cout << "Name: "; // Get up to 256 characters from the keyboard including white space. // Stop reading if encounter the first. If there's any chance of // more than 256 characters you will have to clean up cin with // cin.ignore before the next input. cin.getline(str, 256, ' '); // for char arrays; different from the other getline tmp.name = str; cout << "Quantity: "; cin >> tmp.qty; cout << "Cost: "; cin >> tmp.cost; cout << endl; // see if this record should be added to the array cout << "Add the record to inventory? (y/n) "; cin >> response; if (toupper(response) == 'Y') list[size++] = tmp; } else { cout << "Inventory at full; cannot enter more unit." << endl; system("pause"); }
  • 13. system("cls"); } void dispData(const InventoryRecord list[], int size) { system("cls"); double cost = 0; if(size < 1) { cout << "Nothing to display" << endl; } else { cout << "All Inventory item has been shown" << endl << endl; cout << fixed << setprecision(2); cout << "Item Name Qty Cost" << endl; cout << "~~~~~~~~~~~~~~~~~~" << endl; cout << left; for (int i = 0; i < size; i++) { cout << setw(21) << list[i].name << right << setw(4) << list[i].qty << setw(10) << list[i].cost << left << endl; cost = cost + list[i].cost * list[i].qty; } cout << "~~~~~~~~~~~~~~~~~~~" << endl; cout << right << setw(3) << size; cout << " items listed"; cout << right << setw(19) << cost << endl << endl; } system("PAUSE"); system("cls"); } // Save records to disc void saveFile(const InventoryRecord list[], int size) { ofstream outfi("Inventory.txt");
  • 14. // make sure the file stream is open before doing IO if (!outfi.fail()) { system("cls"); cout << "Saving inventory to the disc "; for(int i = 0; i < size; i++) { outfi << list[i].name << ';' << list[i].qty << ';' << list[i].cost; // Start a new line after all but the last record // Simplifies reading the file as EOF is at end of last line if (i < size-1) outfi << endl; } cout << endl << size << " records writen to the disc." << endl; outfi.close(); system("PAUSE"); system("cls"); } else { cout << "ERROR: problem with file" << endl; system("PAUSE"); system("cls"); } } // Open file and load array void openFile(InventoryRecord list[], int& size) { ifstream infi("Inventory.txt"); string str; stringstream strstrm; // make sure the file stream is open before doing IO if (!infi.fail()) { system("cls"); cout << "Reading inventory from the disc ";
  • 15. size = 0; // overwrite any existing records while(!infi.eof() && size < MAX_SIZE) { // get and store the name getline(infi, str, ';'); list[size].name = str; // get, convert and store the quantity getline(infi, str, ';'); strstrm.str(""); strstrm.clear(); // empty and clear the stringstream strstrm << str; strstrm >> list[size].qty; // get, convert and store the cost getline(infi, str); strstrm.str(""); strstrm.clear(); // empty and clear the stringstream strstrm << str; strstrm >> list[size++].cost; } cout << endl << size << " records read from the disc." << endl; system("PAUSE"); system("cls"); } else { // something went wrong with opening the file cout << "ERROR: problem with file" << endl; system("PAUSE"); system("cls"); } } char getMenuResponse() { char response; cout << endl << "Make your selection" << endl
  • 16. << "(A)dd Record, (D)isplay Records, (O)pen File, (S)ave File, (Q)uit" << endl << "> "; cin >> response; cin.ignore(256, ' '); }