Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(note: in C++) Using an input file similar to the one below, write a program to

ID: 3768258 • Letter: #

Question

(note: in C++) Using an input file similar to the one below, write a program to determine the highest concentration recorded and the number of days the photochemical oxidant concentration exceeded the standard; display number of days and percentage (based on the number of days per month). Use at least two programmer defined functions. Sample Input file: 80 83 79 180 190 200 220 220 200 200 198 225 199 183 160 119 162 180 122 121 121 119 80 83 79 119 121 121 122 119 Implementation: The number of days in the month are determined from input file. The input file can vary in size depending on the month. Once array is populated, the contents of the array can not be changed. At least one function must have an array as a parameter. Sample output: Enter input file name =>list.dat The highest reading recorded was 225 micrograms/m^3 What level is the federal standard =>160 During this month, the federal standard for photochemical oxidants was exceeded on 13 days. Percentage of days for month is 43.3333%

Explanation / Answer

working c++ code compiled on ideone:

#include<iostream>
#include<fstream>
#include<string>
using namespace std;

int main()
{
int n = 0;
int num;
int arr[100];

ifstream File;
File.open("list.dat");
while(!File.eof())
{
File >> arr[n];
n++;
}

File.close();
   int max=0;
   int count=0; // for getting the number of days where the standard was exceeded

for(int i=0;i<n;i++)
{
       if(arr[i]>max)
       max=arr[i]; //finding maximum concentration and storing it in max
  
       if(arr[i]>160)
           count++;
}
  
   cout<<"Standard is "<<160;
   cout<<"Number of days on which standard was exceeded"<<count;
  
   float percentage;
   percentage=(count/n) * 100;
   cout<<"Percentage will be "<<percentage;
  
return 0;
}

I have reading the numbers in the array and then doing using an for loop to check for maximum and count the number of days exceeding the limit.