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

Create a new Visual Studio project and source code file. Copy and paste the code

ID: 3621327 • Letter: C

Question

Create a new Visual Studio project and source code file.
Copy and paste the code below into a source code file.
Add the following functions to your program:
Sum – return a sum of all of the data in the array
CountNmbrsBigger – return a count of the number of data elements in the array that are larger than a given integer
Average – returns an average of the data in an array
High – returns the highest value in the array
Low –returns the lowest value in the array
Find(number) – returns the first index of the location of the number in the array
Test your class by creating a main function and an array with 10 numbers, invoking each function and displaying the results to the screen.
Use the following prototype definition in the creation of your functions:



/******************************************************************
* Programmer: [put your name here]
*
* Date: [put the current date here]
*
* Course: COMP 220
*
* Assignment: Searching & Summarizing Array Data
*
* File name: XXX.cpp [put your initials instead of XXX]
*
* Description: This program contains functions to perform
* basic search and summary operations on a single-dimension array
*
* Assumptions: none
*
* Input: none
*
* Output: screen - display the result of each function to the screen
*
********************************************************************/

#include <iostream>

using namespace std;

int sum(int [], int);
int countNmbrsBigger(int [], int, int);
int average(int [], int);
int high(int [], int);
int low(int [], int);
int find(int [], int, int);


int main (void ){
//test the array class
const int arraySize = 10;
int theArray[arraySize] = {1, 5, 25, 10, 12, 9, 24, 24, 22, 2};

cout << "Sum: " << sum(theArray, arraySize) << endl;
cout << "Count of numbers bigger than 10: " << countNmbrsBigger(theArray, arraySize, 10) << endl;
cout << "Average: " << average(theArray, arraySize) << endl;
cout << "High: " << high(theArray, arraySize) << endl;
cout << "Low: " << low(theArray, arraySize) << endl;
cout << "Find: " << find(theArray, arraySize, 25) << endl;
cout << "Find: " << find(theArray, arraySize, 100) << endl;

}


int sum(int theArray [], int theArraySize){
//returns the sum of the values in theArray

}

int countNmbrsBigger(int theArray [], int theArraySize, int Number){
//count the value in the array greater than
//the parameter

}

int average(int theArray [], int theArraySize){
//average the values in the array

}

int high(int theArray [], int theArraySize){
//find the highest value in the array

}

int low(int theArray [], int theArraySize){
//find the lowest value in the array
int lowValue = theArray[0];
for (int i = 0; i < theArraySize; i++){
if (theArray[i] < lowValue){
lowValue = theArray[i];
}
}
return lowValue;
}

int find(int theArray [], int theArraySize, int theNumber){
//return the subscript of the supplied argument
//return -1 if not found

}



Here is a sample of the program output:



Exercise 2: Two-Dimensional Arrays (20 points)



Objective: Create a C++ console application that can analyze numeric data contained in a two-dimension array of type integer.

ABC Inc monitors the temperature of each of it seven servers throughout the day. Readings are recorded each hour and the data is reviewed every morning to ensure that temperatures are within operating specs throughout the day. You have been assigned the task of creating a program that provides a quick analysis of each day's data. The data is to be read from a two-dimensional array. There will be twenty-four rows each representing an hour during the day. There are eight columns of numbers. The first seven will represent a server temperature and the seventh will represent the server room's air temperature. The program should display a data analysis that includes:

For each server, the high, low and average temperature during the twenty-four hour period
The difference in temperature between the server room and each of the seven servers for each hour of the day. When the temperature difference is greater than or equal to 50 degrees, mark the entry with an asterisk.
Steps:

Create a new Visual Studio project and source code file.
Copy and paste the code below into a source code file.
Complete the requirements of the program as described in the above paragraph.

Use the following code in the creation of your solution:
/******************************************************************
* Programmer: [put your name here]
*
* Date: [put the current date here]
*
* Course: COMP 220
*
* Assignment: Two-dimensional arrays
*
* File name: XXX.cpp [put your initials instead of XXX]
*
* Description: this program analyzes the data from temperature sensors for
* each of the seven computers in a room
*
* Assumptions: all data is type integer
*
* Input: two-dimensional array
*
* Output: screen - Displays results of calculations in table format.
*
********************************************************************/


#include <iostream>

const int NMBROFCLMNS = 8;
const int NMBROFROWS = 24;

void processArray(int TR[][NMBROFCLMNS]);
double avgerage(int [][NMBROFCLMNS], int, int);
int high(int TR[][NMBROFCLMNS], int, int);
int low(int [][NMBROFCLMNS], int, int);
int tempDifference(int [][NMBROFCLMNS], int , int );

int main ( ){
int tempReadings [][NMBROFCLMNS] = {
{96, 94, 95, 100, 115, 97, 92, 65},
{100, 92, 91, 110, 115, 99, 98, 65},
{120, 91, 99, 113, 115, 95, 99, 66},
{97, 99, 100, 114, 115, 100, 100, 66},
{99, 100, 111, 115, 115, 104, 104, 68},
{95, 130, 112, 101, 115, 100, 115, 65},
{94, 90, 95, 100, 105, 97, 120, 64},
{96, 94, 95, 100, 115, 97, 92, 65},
{100, 92, 91, 110, 115, 99, 98, 65},
{120, 91, 99, 113, 115, 95, 99, 66},
{97, 99, 100, 114, 115, 100, 100, 66},
{99, 100, 111, 115, 115, 104, 104, 68},
{95, 130, 112, 101, 115, 100, 115, 65},
{94, 90, 95, 100, 105, 97, 120, 64},
{96, 94, 95, 100, 115, 97, 92, 65},
{100, 92, 91, 110, 115, 99, 98, 65},
{120, 91, 99, 113, 115, 95, 99, 66},
{97, 99, 100, 114, 115, 100, 100, 66},
{99, 100, 111, 115, 115, 104, 104, 68},
{95, 130, 112, 101, 115, 100, 115, 65},
{94, 90, 95, 100, 105, 97, 120, 64},
{99, 100, 111, 115, 115, 104, 104, 68},
{92, 93, 94, 95, 96, 97, 98, 64},
{96, 94, 95, 100, 115, 97, 92, 64} };

processArray(tempReadings);

return 0;
} //end main

void processArray(int temperatures[][NMBROFCLMNS]){
//Create the required tables

//print the table heading
std::cout << "Low / High / Average Temperature Table ";
std::cout << "Unit" << " Low" << " High" << " AVG ";

//Iterate through each clmn of the array and calculate column stats
for (int clmn = 0; clmn < 8; clmn++) {
std::cout << clmn << " "
<< low(temperatures,NMBROFROWS,clmn) << " "
<< high(temperatures,NMBROFROWS,clmn) << " "
<< avgerage(temperatures,NMBROFROWS,clmn) <<" ";
};

//calculate and display the temp difference table
tempDifference(temperatures,NMBROFROWS,NMBROFCLMNS);
}


void printColumn(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//prints the values in the given column (TheClmn)
for (int row = 0; row < nmbrOfRows; row++)
std::cout << theArray[row][TheClmn] << " ";
std::cout << std::endl;
}

int low(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the lowest value in the given column of a two-dimensional array

} //end low

int high(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the highest value in the given column of a two-dimensional array

} //end high

double avgerage(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the average of the values in the given column of a two-dimensional array

} //end average

int tempDifference(int theArray[][NMBROFCLMNS], int nmbrOfRows, int nmbrOfClmns){
//creates a table that contains the difference between
//each computer's temperature and the room temperature
//for each time reading. Mark all differences
//greater than or equal to 50 with an asterisk.
//Formula: differnce = theArray[row][clmn] - theArray[row][7];

} //end temperature Difference




Here is a sample of the program output:


Explanation / Answer

please rate-thanks

average should return a double not an int

in the future 1 question per post!!CRAMSTER rule

/******************************************************************
* Programmer: [put your name here]
*
* Date: [put the current date here]
*
* Course: COMP 220
*
* Assignment: Searching & Summarizing Array Data
*
* File name: XXX.cpp [put your initials instead of XXX]
*
* Description: This program contains functions to perform
* basic search and summary operations on a single-dimension array
*
* Assumptions: none
*
* Input: none
*
* Output: screen - display the result of each function to the screen
*
********************************************************************/

#include <iostream>

using namespace std;

int sum(int [], int);
int countNmbrsBigger(int [], int, int);
int average(int [], int);
int high(int [], int);
int low(int [], int);
int find(int [], int, int);


int main (void ){
//test the array class
const int arraySize = 10;
int theArray[arraySize] = {1, 5, 25, 10, 12, 9, 24, 24, 22, 2};

cout << "Sum: " << sum(theArray, arraySize) << endl;
cout << "Count of numbers bigger than 10: " << countNmbrsBigger(theArray, arraySize, 10) << endl;
cout << "Average: " << average(theArray, arraySize) << endl;
cout << "High: " << high(theArray, arraySize) << endl;
cout << "Low: " << low(theArray, arraySize) << endl;
cout << "Find: " << find(theArray, arraySize, 25) << endl;
cout << "Find: " << find(theArray, arraySize, 100) << endl;
system("pause");
}


int sum(int theArray [], int theArraySize){
//returns the sum of the values in theArray
int i, tot=0;
for(i=0;i<theArraySize;i++)
    tot+=theArray[i];
return tot;
}

int countNmbrsBigger(int theArray [], int theArraySize, int Number){
//count the value in the array greater than
//the parameter
int i, tot=-1;
for(i=0;i<theArraySize;i++)
    if(theArray[i]>Number)
        tot++;
return tot;
}

int average(int theArray [], int theArraySize){
//average the values in the array
return sum(theArray,theArraySize)/theArraySize;
}

int high(int theArray [], int theArraySize){
//find the highest value in the array
int highValue = theArray[0];
for (int i = 0; i < theArraySize; i++){
if (theArray[i] >highValue){
highValue = theArray[i];
}
}
return highValue;
}


int low(int theArray [], int theArraySize){
//find the lowest value in the array
int lowValue = theArray[0];
for (int i = 0; i < theArraySize; i++){
if (theArray[i] < lowValue){
lowValue = theArray[i];
}
}
return lowValue;
}

int find(int theArray [], int theArraySize, int theNumber){
//return the subscript of the supplied argument
//return -1 if not found
int i, n=-1;
for(i=0;i<theArraySize;i++)
    if(theArray[i]==theNumber)
        n=i;
return n;
}

--------------------------------------------------------------------------

/******************************************************************
* Programmer: [put your name here]
*
* Date: [put the current date here]
*
* Course: COMP 220
*
* Assignment: Two-dimensional arrays
*
* File name: XXX.cpp [put your initials instead of XXX]
*
* Description: this program analyzes the data from temperature sensors for
* each of the seven computers in a room
*
* Assumptions: all data is type integer
*
* Input: two-dimensional array
*
* Output: screen - Displays results of calculations in table format.
*
********************************************************************/


#include <iostream>

const int NMBROFCLMNS = 8;
const int NMBROFROWS = 24;

void processArray(int TR[][NMBROFCLMNS]);
double avgerage(int [][NMBROFCLMNS], int, int);
int high(int TR[][NMBROFCLMNS], int, int);
int low(int [][NMBROFCLMNS], int, int);
int tempDifference(int [][NMBROFCLMNS], int , int );

int main ( ){
int tempReadings [][NMBROFCLMNS] = {
{96, 94, 95, 100, 115, 97, 92, 65},
{100, 92, 91, 110, 115, 99, 98, 65},
{120, 91, 99, 113, 115, 95, 99, 66},
{97, 99, 100, 114, 115, 100, 100, 66},
{99, 100, 111, 115, 115, 104, 104, 68},
{95, 130, 112, 101, 115, 100, 115, 65},
{94, 90, 95, 100, 105, 97, 120, 64},
{96, 94, 95, 100, 115, 97, 92, 65},
{100, 92, 91, 110, 115, 99, 98, 65},
{120, 91, 99, 113, 115, 95, 99, 66},
{97, 99, 100, 114, 115, 100, 100, 66},
{99, 100, 111, 115, 115, 104, 104, 68},
{95, 130, 112, 101, 115, 100, 115, 65},
{94, 90, 95, 100, 105, 97, 120, 64},
{96, 94, 95, 100, 115, 97, 92, 65},
{100, 92, 91, 110, 115, 99, 98, 65},
{120, 91, 99, 113, 115, 95, 99, 66},
{97, 99, 100, 114, 115, 100, 100, 66},
{99, 100, 111, 115, 115, 104, 104, 68},
{95, 130, 112, 101, 115, 100, 115, 65},
{94, 90, 95, 100, 105, 97, 120, 64},
{99, 100, 111, 115, 115, 104, 104, 68},
{92, 93, 94, 95, 96, 97, 98, 64},
{96, 94, 95, 100, 115, 97, 92, 64} };

processArray(tempReadings);

return 0;
} //end main

void processArray(int temperatures[][NMBROFCLMNS]){
//Create the required tables

//print the table heading
std::cout << "Low / High / Average Temperature Table ";
std::cout << "Unit" << " Low" << " High" << " AVG ";

//Iterate through each clmn of the array and calculate column stats
for (int clmn = 0; clmn < 8; clmn++) {
std::cout << clmn << " "
<< low(temperatures,NMBROFROWS,clmn) << " "
<< high(temperatures,NMBROFROWS,clmn) << " "
<< avgerage(temperatures,NMBROFROWS,clmn) <<" ";
};

//calculate and display the temp difference table
tempDifference(temperatures,NMBROFROWS,NMBROFCLMNS);
system("pause");
}


void printColumn(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//prints the values in the given column (TheClmn)
for (int row = 0; row < nmbrOfRows; row++)
std::cout << theArray[row][TheClmn] << " ";
std::cout << std::endl;
}

int low(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the lowest value in the given column of a two-dimensional array
int i,l;
l=theArray[0][TheClmn];
for(i=1;i<nmbrOfRows;i++)
      if(theArray[i][TheClmn]<l)
            l=theArray[i][TheClmn];
return l;
} //end low

int high(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the highest value in the given column of a two-dimensional array
int i,h;
h=theArray[0][TheClmn];
for(i=1;i<nmbrOfRows;i++)
      if(theArray[i][TheClmn]>h)
            h=theArray[i][TheClmn];
return h;
} //end high

double avgerage(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the average of the values in the given column of a two-dimensional array
int i,tot=0;
for(i=0;i<nmbrOfRows;i++)
      tot+=theArray[i][TheClmn];
return tot/(double)nmbrOfRows;
} //end average

int tempDifference(int theArray[][NMBROFCLMNS], int nmbrOfRows, int nmbrOfClmns){
//creates a table that contains the difference between
//each computer's temperature and the room temperature
//for each time reading. Mark all differences
//greater than or equal to 50 with an asterisk.
//Formula: differnce = theArray[row][clmn] - theArray[row][7];
int diff,i,j;
std::cout <<"difference table ";
for(i=0;i<nmbrOfRows;i++)
    {std::cout <<i<<" ";
    for(j=0;j<nmbrOfClmns-1;j++)
        {diff=theArray[i][j] - theArray[i][7];
        std::cout <<diff;
       if(diff>50)
          std::cout <<"*";
       std::cout <<" ";
           }
   std::cout <<" ";

}
} //end temperature Difference

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote