Write 3 functions: Write  int readNumbersIntoArray(int numbers[], int size); // Reads up to size numbers or a non-numeric and puts them in the array. // Returns how many numbers read. Write  int minOrMax(int numbers[], int size, bool Max); // Returns the minimum or the maximum value in the array depending on "Max". // If "Max" is true, then it returns the maximum. // If "Max" is false, then it returns the minimum. Write double trimmedAvg(int numbers[], int size); // Returns the trimmed average of the array. // A trimmed average is a normal average but leaves out the first instance of // the smallest and largest value in the array when doing the calculation. // HINT: use calls to minOrMax() to get the largest and smallest number. Write  int main(): // Prompt the user for between 3 and 20 numbers and use readNumbersIntoArray() to // read them into an array. Print an error message and exit if less than three numbers. // Print out the min, max, and trimmedAverage of the array using calls to minOrMax() and // trimmedAvg(). User input is shown in bold below: // Sample run 1: Enter from 3 to 20 numbers followed by a non-numeric:  1 2 q Must be between 3 and 20 numbers! // Sample run 2: Enter from 3 to 20 numbers followed by a non-numeric: -8 2 3 -2 57 q Minimum value in the array: -8 Maximum value in the array: 57 Trimmed average of the array: 1 // Sample run 3: Enter from 3 to 20 numbers followed by a non-numeric:  3, -22, 5, 68, 21, -6, 2 q Minimum value in the array: -22 Maximum value in the array: 68 Trimmed average of the array: 5 Write program C++ program with comments. Here is code #include #include using namespace std; // Function to read numbers from user input and store them in an array int readNumbersIntoArray(int numbers[], int size) {     int num;     int count = 0;          cout << "Enter from 3 to 20 numbers followed by a non-numeric: " << endl;     while (cin >> num) {         if (count == size) {             break;         }         numbers[count++] = num;     }          // Clear the error flag in case of non-numeric input     cin.clear();     cin.ignore(numeric_limits::max(), '\n');          return count; } // Function to find the minimum or maximum value in the array int minOrMax(int numbers[], int size, bool Max) {     int result = numbers[0];          for (int i = 1; i < size; i++) {         if (Max && numbers[i] > result) {             result = numbers[i];         }         if (!Max && numbers[i] < result) {             result = numbers[i];         }     }          return result; } // Function to calculate the trimmed average of the array double trimmedAvg(int numbers[], int size) {     int minVal = minOrMax(numbers, size, false); // Get the minimum value     int maxVal = minOrMax(numbers, size, true);  // Get the maximum value     double sum = 0;     int count = 0;          for (int i = 0; i < size; i++) {         if (numbers[i] != minVal && numbers[i] != maxVal) {             sum += numbers[i];             count++;         }     }          return sum / count; } int main() {     const int maxSize = 20;     const int minSize = 3;     int numbers[maxSize];          int numCount = readNumbersIntoArray(numbers, maxSize);          if (numCount < minSize) {         cout << "Must be between 3 and 20 numbers!" << endl;         return 1;     }          int minVal = minOrMax(numbers, numCount, false);     int maxVal = minOrMax(numbers, numCount, true);     double trimmedAverage = trimmedAvg(numbers, numCount);          cout << "Minimum value in the array: " << minVal << endl;     cout << "Maximum value in the array: " << maxVal << endl;     cout << "Trimmed average of the array: " << trimmedAverage << endl;          return 0; } Some of error I am getting and attaching picture of it and bottom I paste error 3 message. Could you please fix it?      Source.cpp: In function ‘bool testPassed(std::ofstream&)’: Source.cpp:83:39: error: cannot convert ‘double*’ to ‘int*’    83 |    double studentResultMax = minOrMax(a,L,true);       |                                       ^       |                                       |       |                                       double* Source.cpp:33:18: note:   initializing argument 1 of ‘int minOrMax(int*, int, bool)’    33 | int minOrMax(int numbers[], int size, bool Max) {       |              ~~~~^~~~~~~~~ Source.cpp:84:39: error: cannot convert ‘double*’ to ‘int*’    84 |    double studentResultMin = minOrMax(a,L,false);       |                                       ^       |                                       |       |                                       double* Source.cpp:33:18: note:   initializing argument 1 of ‘int minOrMax(int*, int, bool)’    33 | int minOrMax(int numbers[], int size, bool Max) {       |              ~~~~^~~~~~~~~ Source.cpp:81:17: warning: unused variable ‘EPS’ [-Wunused-variable]    81 |    const double EPS=0.001;       |                 ^~~

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write 3 functions:

Write 

int readNumbersIntoArray(int numbers[], int size);

// Reads up to size numbers or a non-numeric and puts them in the array.

// Returns how many numbers read.

Write 

int minOrMax(int numbers[], int size, bool Max);

// Returns the minimum or the maximum value in the array depending on "Max".

// If "Max" is true, then it returns the maximum.

// If "Max" is false, then it returns the minimum.

Write

double trimmedAvg(int numbers[], int size);

// Returns the trimmed average of the array.

// A trimmed average is a normal average but leaves out the first instance of // the smallest and largest value in the array when doing the calculation.

// HINT: use calls to minOrMax() to get the largest and smallest number.

Write 

int main():

// Prompt the user for between 3 and 20 numbers and use readNumbersIntoArray() to

// read them into an array. Print an error message and exit if less than three numbers.

// Print out the min, max, and trimmedAverage of the array using calls to minOrMax() and

// trimmedAvg().

User input is shown in bold below:

// Sample run 1: Enter from 3 to 20 numbers followed by a non-numeric: 

1 2 q

Must be between 3 and 20 numbers! // Sample run 2:

Enter from 3 to 20 numbers followed by a non-numeric:

-8 2 3 -2 57 q

Minimum value in the array: -8

Maximum value in the array: 57

Trimmed average of the array: 1

// Sample run 3:

Enter from 3 to 20 numbers followed by a non-numeric: 

3, -22, 5, 68, 21, -6, 2 q

Minimum value in the array: -22

Maximum value in the array: 68

Trimmed average of the array: 5

Write program C++ program with comments.

Here is code

#include <iostream>
#include <limits>

using namespace std;

// Function to read numbers from user input and store them in an array
int readNumbersIntoArray(int numbers[], int size) {
    int num;
    int count = 0;
    
    cout << "Enter from 3 to 20 numbers followed by a non-numeric: " << endl;
    while (cin >> num) {
        if (count == size) {
            break;
        }
        numbers[count++] = num;
    }
    
    // Clear the error flag in case of non-numeric input
    cin.clear();
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    
    return count;
}

// Function to find the minimum or maximum value in the array
int minOrMax(int numbers[], int size, bool Max) {
    int result = numbers[0];
    
    for (int i = 1; i < size; i++) {
        if (Max && numbers[i] > result) {
            result = numbers[i];
        }
        if (!Max && numbers[i] < result) {
            result = numbers[i];
        }
    }
    
    return result;
}

// Function to calculate the trimmed average of the array
double trimmedAvg(int numbers[], int size) {
    int minVal = minOrMax(numbers, size, false); // Get the minimum value
    int maxVal = minOrMax(numbers, size, true);  // Get the maximum value
    double sum = 0;
    int count = 0;
    
    for (int i = 0; i < size; i++) {
        if (numbers[i] != minVal && numbers[i] != maxVal) {
            sum += numbers[i];
            count++;
        }
    }
    
    return sum / count;
}

int main() {
    const int maxSize = 20;
    const int minSize = 3;
    int numbers[maxSize];
    
    int numCount = readNumbersIntoArray(numbers, maxSize);
    
    if (numCount < minSize) {
        cout << "Must be between 3 and 20 numbers!" << endl;
        return 1;
    }
    
    int minVal = minOrMax(numbers, numCount, false);
    int maxVal = minOrMax(numbers, numCount, true);
    double trimmedAverage = trimmedAvg(numbers, numCount);
    
    cout << "Minimum value in the array: " << minVal << endl;
    cout << "Maximum value in the array: " << maxVal << endl;
    cout << "Trimmed average of the array: " << trimmedAverage << endl;
    
    return 0;
}

Some of error I am getting and attaching picture of it and bottom I paste error 3 message. Could you please fix it? 

   
Source.cpp: In function ‘bool testPassed(std::ofstream&)’:
Source.cpp:83:39: error: cannot convert ‘double*’ to ‘int*’
   83 |    double studentResultMax = minOrMax(a,L,true);
      |                                       ^
      |                                       |
      |                                       double*
Source.cpp:33:18: note:   initializing argument 1 of ‘int minOrMax(int*, int, bool)’
   33 | int minOrMax(int numbers[], int size, bool Max) {
      |              ~~~~^~~~~~~~~
Source.cpp:84:39: error: cannot convert ‘double*’ to ‘int*’
   84 |    double studentResultMin = minOrMax(a,L,false);
      |                                       ^
      |                                       |
      |                                       double*
Source.cpp:33:18: note:   initializing argument 1 of ‘int minOrMax(int*, int, bool)’
   33 | int minOrMax(int numbers[], int size, bool Max) {
      |              ~~~~^~~~~~~~~
Source.cpp:81:17: warning: unused variable ‘EPS’ [-Wunused-variable]
   81 |    const double EPS=0.001;
      |                 ^~~

 

Source.cpp: In function "bool test Passed (std::ofstream&)':
Source.cpp:84:39: error: cannot convert 'double* to 'int**
84 1
double student Resulta = trimmedAvg (a, L);
I
double*
Source.cpp:49:23: note: initializing argument 1 of 'double trimmedAvg (int*, int)'
49 | double trimmedAvg (int numbers [], int size) {
I
Source.cpp:85:39: error: cannot convert 'double*' to 'int**
double studentResultb = trimmedAvg (b, L);
85 1
I
double*
Source.cpp:49:23: note: initializing argument 1 of 'double trimmedAvg (int*, int)'
49 | double trimmedAvg (int numbers [], int size) {
Transcribed Image Text:Source.cpp: In function "bool test Passed (std::ofstream&)': Source.cpp:84:39: error: cannot convert 'double* to 'int** 84 1 double student Resulta = trimmedAvg (a, L); I double* Source.cpp:49:23: note: initializing argument 1 of 'double trimmedAvg (int*, int)' 49 | double trimmedAvg (int numbers [], int size) { I Source.cpp:85:39: error: cannot convert 'double*' to 'int** double studentResultb = trimmedAvg (b, L); 85 1 I double* Source.cpp:49:23: note: initializing argument 1 of 'double trimmedAvg (int*, int)' 49 | double trimmedAvg (int numbers [], int size) {
Source.cpp: In function 'bool testPassed (std::ofstream&)':
Source.cpp:83:39: error: cannot convert 'double*' to 'int**
83 | double student ResultMax = minorMax (a, L, true);
I
double*
Source.cpp:33:18: note: initializing argument 1 of 'int minorMax (int*, int, bool)'
33 | int minorMax (int numbers [], int size, bool Max) {
I
~~~~
Source.cpp:84:39: error: cannot convert 'double*' to 'int**
double studentResultMin = minorMax (a, L, false);
84 |
I
I
double*
Source.cpp:33:18: note: initializing argument 1 of 'int minorMax (int*, int, bool)'
33 | int minorMax (int numbers [], int size, bool Max) {
I
Source.cpp:81:17: warning: unused variable 'EPS' [-Wunused-variable]
81 I const double EPS=0.001;
Transcribed Image Text:Source.cpp: In function 'bool testPassed (std::ofstream&)': Source.cpp:83:39: error: cannot convert 'double*' to 'int** 83 | double student ResultMax = minorMax (a, L, true); I double* Source.cpp:33:18: note: initializing argument 1 of 'int minorMax (int*, int, bool)' 33 | int minorMax (int numbers [], int size, bool Max) { I ~~~~ Source.cpp:84:39: error: cannot convert 'double*' to 'int** double studentResultMin = minorMax (a, L, false); 84 | I I double* Source.cpp:33:18: note: initializing argument 1 of 'int minorMax (int*, int, bool)' 33 | int minorMax (int numbers [], int size, bool Max) { I Source.cpp:81:17: warning: unused variable 'EPS' [-Wunused-variable] 81 I const double EPS=0.001;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education