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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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
立
Transcribed Image Text: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 立
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
Transcribed Image Text: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
Expert Solution
Step 1:

Store the text in data.txt

Computer Engineering homework question answer, step 1, image 1

Step 2: Code Text

#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;
}

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY