please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the first n letters of the name of the item Change any record in the file (Note: if this option chosen, then the whole record must be reentered even if the user wants to change only one or more fields) Display all records Prepare a report containing: The total wholesale value of the inventory The total retail value of the inventory The total quantity of all values in the inventory. Input validation: The program should not accept quantities or wholesale or retail costs less than 0.
Screenshot of the Code:
Sample Output:
Code to Copy:
//Include the header file for visual studio.
#include "stdafx.h"
//Include the header files.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
//Declare the structure Item_information.
struct Item_information
{
//Craete the variables.
string Item_name;
int Quantity_on_hand;
double wholesale_cost;
double retail_cost;
};
//Define the function Add_the_items to add the record.
void Add_the_items(vector<Item_information*>& store)
{
//Declare the variable of bool type to check the cost.
bool flag = false;
//Create an object of the structure Item_information.
Item_information* Item = new Item_information();
//Begin the do while loop.
do
{
//Prompt the user to enter the name.
cout << "Enter the name of the Item. " << endl;
cin >> Item->Item_name;
//Prompt the user to enter the quantity.
cout << "Enter the Quantity_on_hand. " << endl;
cin >> Item->Quantity_on_hand;
//Prompt the user to enter the wholesale cost.
cout << "Enter the whole sale cost." << endl;
cin >> Item->wholesale_cost;
//Prompt the user to enter the retail cost.
cout << "Enter the retail cost" << endl;
cin >> Item->retail_cost;
//check the wholesale cost and retail cost.
if (Item->wholesale_cost < 0
|| Item->retail_cost < 0)
flag = false;
else flag = true;
}
while (!flag);
store.push_back(Item);
}
//Define the function Single_record_display to display a single record.
void Single_record_display(vector<Item_information*>& store)
{
//Declare a variable of type string.
string search_item;
//Enter the name of the record to search.
cout << "Enter item to be search : ";
cin >> search_item;
//Start the for loop to display the record.
for (int i = 0; i < store.size(); i++)
{
string itemname = store[i]->Item_name;
if (itemname.compare(0, search_item.size(),
search_item) == 0)
{
//Display the infomation of the record.
cout << "Name of the item : \t"
<< store[i]->Item_name << endl
<< "Quantity_on_hand : \t"
<< store[i]->Quantity_on_hand << endl
<< "Wholesale cost : \t"
<< store[i]->wholesale_cost << endl
<< "Retail cost : \t"
<< store[i]->retail_cost << endl;
}
}
}
//Define the function Display_all-records to display all records.
void Display_all_records(vector<Item_information*>& store)
{
cout << "All the entered recordes are : " << endl;
//Begin the loop for displaying all records.
for (int i = 0; i < store.size(); i++)
{
//Display the infomation of the record.
cout << "Name of the item : \t"
<< store[i]->Item_name << endl
<< "Quantity_on_hand : \t"
<< store[i]->Quantity_on_hand << endl
<< "Wholesale cost : \t"
<< store[i]->wholesale_cost << endl
<< "Retail cost : \t"
<< store[i]->retail_cost << endl;
}
}
//Define the function Change_the_record to change a particular record.
void Change_the_record(vector<Item_information*>& store)
{
//Prompt the user to enter the record to be changed.
cout << "Enter the item name to change: ";
//Declare a variable of type string.
string change_item_name;
cin >> change_item_name;
//Start the for loop to enter the record.
for (int i = 0; i < store.size(); i++)
{
//Change the item.
if (change_item_name.compare(store[i]->Item_name)
== 0)
{
//Change the name and other specifications.
cout << "Name of the change item : \t";
cin >> store[i]->Item_name;
cout << "Quantity_on_hand : \t";
cin >> store[i]->Quantity_on_hand;
cout << "Wholesale cost : \t";
cin >> store[i]->wholesale_cost;
cout << "Retail cost : \t";
cin >> store[i]->retail_cost;
}
}
}
//Define the function Record_report to prepare the report.
void Record_report(vector<Item_information*>& store)
{
cout << "Report " << endl;
//Declare the variables and initialize it to 0.
int total_Quantity = 0;
double total_Wholesale_cost = 0;
double total_Retail_cost = 0;
//Begin the loop.
for (int i = 0; i < store.size(); i++)
{
//Compute the total qualtity, wholesale_cost
//and the retail_cost.
total_Quantity += store[i]->Quantity_on_hand;
total_Wholesale_cost += store[i]->wholesale_cost;
total_Retail_cost += store[i]->retail_cost;
}
//Display the report.
cout << "Overall report of the inventory " << endl;
cout << " Total Quantity : "
<< total_Quantity << endl;
cout << " Total WholesaleCost : "
<< total_Wholesale_cost << endl;
cout << " Total RetailCost : "
<< total_Retail_cost << endl;
}
//Menu_of_tasks function to display the menu.
void Menu_of_tasks()
{
cout << endl;
//Menu of different tasks.
cout << "Choose the tasks." << endl;
//For exit the program.
cout << "For Exit : 0" << endl;
//For adding new records.
cout << "Adding_New_Records : 1" << endl;
//Display a single record entered.
cout << "Display a single record : 2" << endl;
//For display all the entered records entered till
//now.
cout << "Display all the records : 3" << endl;
//For changing the record.
cout << "Change the records : 4" << endl;
//Report of all the records entered.
cout << "Report of the records : 5" << endl;
}
//Begin the main() function.
int main()
{
vector<Item_information*> store;
//Declare and initialize the variable choice.
int choice = 1;
do
{
//Call the function menu();
Menu_of_tasks();
//Input the choice.
cin >> choice;
//Start the switch case.
switch (choice)
{
//Add the records to the inventory.
case 1:
//Call the function Add_the-items().
Add_the_items(store);
break;
//Display the single record.
case 2:
//Call the function Single_record_display()
Single_record_display(store);
break;
//Display all records.
case 3:
//Call the function Display_all-records().
Display_all_records(store);
break;
//Change the record in the inventory.
case 4:
//Call the function Change_the_record().
Change_the_record(store);
break;
//Prepare report of the inventory.
case 5:
//Call the function Record_report().
Record_report(store);
break;
}
} while (choice != 0);
}
please write in C++ Write a program that uses a structure to store the following inventory...
Inventory Program (C++) Write a program that uses a structure to store the following inventory data in a file: - Item Description -Quantity on Hand -Wholesale cost -Retail cost -Date Added to Inventory The program should have a menu that allows the user to perform the following tasks: -Add new records to file -Display any record in the file -Change any record in the file Input Validation: The program should not accept quantities, or wholesale or retail costs, less than...
Write a C++ program that uses a structure to store the following inventory information in a file: ⦁ Item description, Quantity on hand, Wholesale cost, Retail cost, and Date added to inventory. ⦁ Use a char array for item description and date. ⦁ The program should have a menu that allows the user to perform the following tasks: i. Add a new record at the end of the file. ii. Display any record in the file. iii. Change any record...
Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for...
Write a program (C++) that shows Game sales. The program should use a structure to store the following data about the Game sale: Game company Type of Game (Action, Adventure, Sports etc.) Year of Sale Sale Price The program should use an array of at least 3 structures (3 variables of the same structure). It should let the user enter data into the array, change the contents of any element and display the data stored in the array. The program...
I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...
Write a program to keep track of the inventory of grocery store. Write a test program that prompts the user to enter how many items of inventory the store has. After that enter item name, quantity and price of each item in three different arrays called Itemname, Quantity and Price. Than calculate the Total=Quantity*Price of items in store and FinalTotal of all the items and print in following exact format using array: Sample run of program: Enter number of items...
You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...
Customer Accounts This program should be designed and written by a team of students. Here are some suggestions: Write a program that uses a structure to store the following information about a customer account: • Name • Address • City, state, and ZIP • Telephone number • Account balance • Date of last payment The structure should be used to store customer account records in a file. The program should have a menu that lets the user perform the following...
C++ program Write a C++ program to manage a hospital system, the system mainly uses file handling to perform basic operations like how to add, edit, search, and delete record. Write the following functions: 1. hospital_menu: This function will display the following menu and prompt the user to enter her/his option. The system will keep showing the menu repeatedly until the user selects option 'e' from the menu. Arkansas Children Hospital a. Add new patient record b. Search record c....
In C++ write a simple menu program that displays a menu for the user in an object-oriented technique. The menu should keep showing up until the user chooses to quit. Also, there is a sub-menu inside a menu. The user should get at least a line displayed after he or she chooses that particular option meaning if the user presses 1 for the read actors from the file. The output can look like "reading actors from a file" and then...