Plz solve with one dimintion array: DATA.txt chair 5 2 9 low round_table1 10 4 9 medium square_table 5 3 9 low stand_lamp1 6 1 17 medium pillow_cover1 9 2 15 low BLUE_chair 8 2.7 15 high X_chair 5 2 9 low round_table2 10 4 4 medium square_table 5 2 9 low stand_lamp2 6 1 17 medium pillow_cover2 9 4 15 low round_lamp 8 3 13 high
Plz solve with one dimintion array:
DATA.txt
chair 5 2 9 low
round_table1 10 4 9 medium
square_table 5 3 9 low
stand_lamp1 6 1 17 medium
pillow_cover1 9 2 15 low
BLUE_chair 8 2.7 15 high
X_chair 5 2 9 low
round_table2 10 4 4 medium
square_table 5 2 9 low
stand_lamp2 6 1 17 medium
pillow_cover2 9 4 15 low
round_lamp 8 3 13 high
![2 hw4 final.pdf - Adobe Reader
Eile Edit View Window Help
O Open
100%
Tools
Fill & Sign
Comment
Sign In
Problem:
v Export PDF
Adobe ExportPDF
A company has stock of many goods, and they want to filter the stock so
Convert PDF files to Word or Excel
online.
that some of the materials can go on sale. The stock information recorded
Select PDF File:
in a file"data.txt" as shown in the sample. (in the following sequence)
1 hw4 final.pdf
1 file / 636 KB
(item name, price_perunit, profit, months_of_stocking, customer_reviews )
Convert To:
Microsoft Word (".docx)
Recognize Text in English(U.S.)
Change
hw4.cpp
data.bxt
t x
chair
5
9.
low
round_table1
square table
stand lamp1
pillow cover1
BLUE chair
medium
low
medium
10
5
3
9.
Convert
17
15
low
2.7
15
high
• Create PDF
X_chair
round table2
9
low
10
4
medium
• Edit PDF
square_table
stand lamp2
pillow_cover2
9
low
17
medium
4
• Combine PDF
15
low
round lamp
3.
13
high
• Send Files
• Store Files
11:12 AM
P Type here to search
Ae
Pr
a
4») ENG
12/23/2020
立](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc20600f4-c159-4675-b0fc-c15947bacff4%2F602ce722-3c0a-4a89-8770-c06f342fe400%2F54vn6tc_processed.jpeg&w=3840&q=75)
![hw4 final.pdf - Adobe Reader
Eile Edit View Window Help
O Open
2
4
66.7%
Tools
Fill & Sign
Comment
Sign In
The sale policy of the company depends on many factors according to the
v Export PDF
following.
• if item in stock more than 8 months and item profit is more
Adobe ExportPDF
than average profit of all items
Convert PDF files to Word or Excel
online.
yes - if customer reviews low quality
Select PDF File:
• yes - sale 50%
• no - if customer reviews medium quality
2 hw4 final.pdf
yes – sale 30%
• no - sale 15%
no- if item profit more than 8% of the item price
• Yes – if in stock more than 1 year
o Yes sale 40%
o no- not on sale
• No - not on sale
1 file / 636 KB
Convert To:
Microsoft Word (*.docx)
Recognize Text in English(U.S.)
Change
Write a C++ program that reads the information from "data.txt" input file
Convert
into 5 arrays, then processes these arrays to produce three arrays, first
array holds the items on sale, second array holds percentage of sale , and
the third one holds the items without sale. Print these arrays on the screen
• Create PDF
to produce the following output.
• Edit PDF
Sample output:
• Combine PDF
CAUers nDesktoA2ycOMPOry programtryDetugnye
Sale items
e
• Send Files
percentage
*********** ****
• Store Files
round table1
souare_table
stand lanp1
pillow cover1
BLUE chair
stand lamp2
40
p
low_cover2
50
round lamp
15
Non Sale items
..*****......
chair
X chair
round_table2
square table
Press any key to continue..
11:12 AM
P Type here to search
Ae
Pr
O G 40) ENG
12/23/2020](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc20600f4-c159-4675-b0fc-c15947bacff4%2F602ce722-3c0a-4a89-8770-c06f342fe400%2Fi61y4mn_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Store the text in data.txt
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main()
{
string line;
ifstream file("data.txt");
string item_name[20];
int price_perunit[20];
int profit[20];
int months_of_stocking[20];
string customer_reviews[20];
int i = 0;
while (getline(file, line)) {
stringstream linestream(line);
string data;
int j = 0;
while (getline(linestream, data, '\t')) {
switch (j) {
case 0:
item_name[i] = data;
break;
case 1:
price_perunit[i] = stoi(data);
break;
case 2:
profit[i] = stoi(data);
break;
case 3:
months_of_stocking[i] = stoi(data);
break;
case 4:
customer_reviews[i] = data;
break;
default:
break;
}
j++;
}
i++;
}
int array_size = i;
string items_on_sale[array_size];
int percentage_of_sale[array_size];
string items_without_sale[array_size];
int total_profit = 0;
for (int i = 0; i < array_size; i++) {
total_profit += profit[i];
}
int avg_profit = total_profit / array_size;
int ios_index = 0;
int pos_index = 0;
int iws_index = 0;
for (int i = 0; i < array_size; i++) {
if (months_of_stocking[i] > 8 && profit[i] > avg_profit) {
if (customer_reviews[i] == "low") {
items_on_sale[ios_index++] = item_name[i];
percentage_of_sale[pos_index++] = 50;
} else if (customer_reviews[i] == "medium") {
items_on_sale[ios_index++] = item_name[i];
percentage_of_sale[pos_index++] = 30;
} else {
items_on_sale[ios_index++] = item_name[i];
percentage_of_sale[pos_index++] = 15;
}
} else if ((profit[i] * 100) / price_perunit[i] > 8) {
if (months_of_stocking[i] > 12) {
items_on_sale[ios_index++] = item_name[i];
percentage_of_sale[pos_index++] = 40;
} else {
items_without_sale[iws_index++] = item_name[i];
}
} else {
items_without_sale[iws_index++] = item_name[i];
}
}
cout << "\tSale items\t\tpercentage" << endl;
for (int i = 0; i < ios_index; i++) {
cout << "\t" << items_on_sale[i] << "\t\t" << percentage_of_sale[i] << endl;
}
cout << endl;
cout << "\n\t\tNon sale items" << endl;
for (int i = 0; i < iws_index; i++) {
cout << "\t\t" << items_without_sale[i] << endl;
}
return 0;
}
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)