Question

You are to write a C++ program to produce an inventory report for a local company....

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. 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 it he 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 Bubble Sort method to sort.

Use ‘typedef’ for array declarations. The output should be printed to a file.

​Read the data in from invt.txt.

​invt.txt shows the following data inside the file:

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

Homework Answers

Answer #1

Here is the partially working code for you:

#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
typedef struct
{
char itemName[20];
int itemNumber;
int quantity;
double price;
int safeStock;
double stockValue;
double percentOfStock;
bool flag;
}Item;

void printItem(Item item)
{
cout<<item.itemName<<" "<<item.itemNumber<<" "<<item.quantity<<" "<<item.price<<" "<<item.safeStock;
cout<<" "<<item.stockValue<<" "<<item.flag<<endl;
}
int main()
{
ifstream fin;
ofstream fout;
Item items[100];
//Reads the input from file invt.txt
int count = 0;
fin.open("invt.txt");
if(!fin.is_open())
{
cout<<"Unable to open file."<<endl;
return 1;
}
stringstream buffer;
string line;
char temp[20];
double totalValue = 0;
while(!fin.eof())
{
getline(fin, line);
buffer.str(line);
buffer.read(items[count].itemName, 20);
//strcpy(items[count].itemName, temp);
buffer.read(temp, 4);
buffer.read(temp, 5);
items[count].itemNumber = atoi(temp);
buffer.read(temp, 5);
buffer.read(temp, 3);
items[count].quantity = atoi(temp);
buffer.read(temp, 2);
buffer.read(temp, 6);
items[count].price = atof(temp);
buffer.read(temp, 4);
buffer.read(temp, 3);
//cout<<"**"<<temp<<"**";
items[count].safeStock = atoi(temp);
items[count].stockValue = items[count].price * items[count].quantity;
totalValue += items[count].stockValue;
printItem(items[count]);
count++;
if(items[count].quantity < items[count].safeStock)
items[count].flag = true;
else
items[count].flag = false;
}
cout<<"The total stock value is: "<<totalValue<<endl;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
You are to write a program to produce an inventory report for a local company. Your...
You are to write a 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. 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...
Goals: Write a program that uses binary files. Write a program that stores records to a...
Goals: Write a program that uses binary files. Write a program that stores records to a binary file. C++ Requirements: Write a program that includes a structure named Part that contains the following fields: name - a character array of 20 elements that stores the name of the part. qty - an integer that stores the number of parts in stock. price - a double that stores the price of the part. Create three Part variables in main, and fill...
In this assignment, you’ll make an inventory system for a store’s items, including produce and books....
In this assignment, you’ll make an inventory system for a store’s items, including produce and books. The starter program is an inventory system for only produce. 1. Include the price of an item by adding to the Item class the protected data member int priceInDollars that stores the price in dollars of an individual item. Write a public function SetPrice with a single int parameter prcInDllrs and returns nothing. SetPrice assigns the value of prcInDllrs to priceInDollars. Modify the AddItemToInventory...
You are in change of inventory for a manufacturing company, and you are given the following...
You are in change of inventory for a manufacturing company, and you are given the following information: Table 3: Inventory Characteristics Average Annual Demand 7800 Standard Deviation for Annual Demand 2600 Leadtime 2 weeks Holding or Carrying Cost 15% per year Fixed Delivery Cost per Shipment $200 Price (value) per Item $80 Stockout cost per Item $20 Probability of being in stock during leadtime 85% 5 What is your optimal economic order quantity (integer)? 6 What is the reorder point?...
Topics Arrays Accessing Arrays Description Write a C++ program that will display a number of statistics...
Topics Arrays Accessing Arrays Description Write a C++ program that will display a number of statistics relating to data supplied by the user. The program will ask the user to enter the number of items making up the data. It will then ask the user to enter data items one by one. It will store the data items in a double array. Then it will perform a number of statistical operations on the data. Finally, it will display a report...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
**[70 pts]** You will be writing a (rather primitive) online store simulator. It will have these...
**[70 pts]** You will be writing a (rather primitive) online store simulator. It will have these classes: Product, Customer, and Store. All data members of each class should be marked as **private** (a leading underscore in the name). Since they're private, if you need to access them from outside the class, you should do so via get or set methods. Any get or set methods should be named per the usual convention ("get_" or "set_" followed by the name of...
You are a database consultant with Ace Software, Inc., and have been assigned to develop a...
You are a database consultant with Ace Software, Inc., and have been assigned to develop a database for the Mom and Pop Johnson video store in town. Mom and Pop have been keeping their records of videos and DVDs purchased from distributors and rented to customers in stacks of invoices and piles of rental forms for years. They have finally decided to automate their record keeping with a relational database. You sit down with Mom and Pop to discuss their...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT