Answer to Question #208678 in C++ for umara

Question #208678

 We are working in a packaging factory where 100 boxes are packed in a day where each weigh around 1 Kg. To maintain sufficient accuracy, the machine picks 5 boxes in a row and find the average weight. The same processis repeated for all the packages. The average weight should be in a limit of 1 Kg ±2%. The average weight should be stored in an array. It should also report the index of boxes not satisfying the weight criteria. 


1
Expert's answer
2021-06-20T08:10:03-0400
#include <iostream>
#include <vector>

using namespace std;

double w[100];
double avg[20];

vector<int> notsatisfies;

int main() 
{
  for(int i=0; i<100; i++) {
    cin>>w[i];
    if (0.98 > w[i] || 1.02 < w[i])
      notsatisfies.push_back(i+1);
  }
  for(int i=0; i<20; i++) {
    avg[i]=(w[5*i]+w[5*i+1]+w[5*i+2]+w[5*i+3]+w[5*i+4])/5;
  }
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS