(C++) Use the data format presented below for products and customers: The existi
ID: 3877714 • Letter: #
Question
(C++)
Use the data format presented below for products and customers:
The existing information for customers is as follows:
- First name
- Last name
- Shipping address
- Billing address
- Phone number
- Customer ID
_______________________
The information for the product is as follows:
- Product ID
- Name
- Description
- Wholesale price
- Sale price
- Inventory
___________________________
Use the information provided in the following scenario:
- The number of products in the system is about 300 elements.
- The memory in the system is capable of holding all of the elements in the products list.
- The amount of products is not expected to grow in the next 5 years.
- The number of customers in the system is about 5,000 elements.
- The memory in the system is not capable of holding all of the elements in the customers list.
- The amount of customers is not expected to grow at a rate of 10% every year.
___________________________________
Complete the following for this assignment:
- Select a sort and a search algorithm to solve the new features requested by the marketing department: Hash table or Heap for search and Priority Queue or normal Array with quicksort algorithm for sort
- Search for a specific product, and print a sorted list for all of the customers, using the last name as a key.
- Explain the reasons for your selection, considering elements such as Big Oh, the number of elements, and the resources in the system in your explanation.
Explanation / Answer
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
char sg [20];
char C_name [20];
char Delivery_Add [20];
char Country [20];
char Post_code [20];
char Date [20];
char Product [20];
int Invoice_num;
int Contact_num;
int Order;
int qty;
int FAX;
char TRN;
int Sell_price;
int product_cost;
int ADD;
int Edit;
int Delete;
int main () {
//menu and Welcome
cout<<" ***************************"<< endl;
cout<<" * *"<< endl;
cout<<" * NEW INVOICE *"<< endl;
cout<<" * *"<< endl;
cout<<" ***************************"<< endl;
//filenaming
//Note TRN is the filename
cout << "Enter TRN: ";
std::string TRN;
cin >> TRN;
cout<<endl;
//menu
cout<< "Fill in the required fields:";
cout<< endl;
cout<<endl;
cout<< "First Name :";
cin>>sg;
cout<< endl;
// Open file
ofstream myfile(TRN.c_str());
if (myfile.is_open())
{
//this code block takes in the data..it has not been written to the file yet.
cout<< "Last Name :";
cin>> C_name;
cout<< endl;
cout<< "Delivery Address :";
cin>> Delivery_Add;
cout<< endl;
cout<< "Contact number :";
cin>> Contact_num;
Invoice_num + 1;
cout<< endl;
cout<< "Country :";
cin>>Country;
cout<< endl;
cout<< "Product :";
cin>>Product;
cout<< endl;
cout<< "Quantity? :";
cin>> qty;
cout<< endl;
//this section writes the data in the file
myfile<< "First Name :";
myfile<<sg;
myfile<< endl;
myfile << endl;
myfile<< "Last Name :";
myfile<<C_name;
myfile<< endl;
myfile << endl;
myfile<< "Delivery Address :";
myfile<<Delivery_Add;
myfile<< endl;
myfile << endl;
myfile<< "Contact number :";
myfile<<Contact_num;
myfile << endl;
myfile << endl;
myfile<<"Country :";
myfile<<Country;
myfile << endl;
myfile << endl;
myfile<< "Item :";
myfile<<Product;
myfile<< endl;
myfile << endl;
myfile<< "Amt :";
myfile<<qty;
myfile << endl;
myfile<< Invoice_num;
cout<<endl;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "The Invoice was created at: %s", asctime (timeinfo) );
myfile<<asctime (timeinfo);
myfile.close();
}
else cout << "Unable to open file";
system("PAUSE");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.