Objective: Create a C++ console application that can analyze numeric data contai
ID: 3636376 • Letter: O
Question
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:
1. Create a new Visual Studio project and source code file.
2. Copy and paste the code below into a source code file.
3. 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
Explanation / Answer
please rate - thanks
message me before rating if any problem
be sure to fill in the correct info in the comment
/******************************************************************
* 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);
system("pause");
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
int i,ind=0;
for(i=1;i<nmbrOfRows;i++)
if(theArray[i][TheClmn]<theArray[ind][TheClmn])
ind=i;
return theArray[ind][TheClmn];
} //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,ind=0;
for(i=1;i<nmbrOfRows;i++)
if(theArray[i][TheClmn]>theArray[ind][TheClmn])
ind=i;
return theArray[ind][TheClmn];
} //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,sum=0;
for(i=0;i<nmbrOfRows;i++)
sum+=theArray[i][TheClmn];
return (double)sum/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 i,j, diff;
std::cout<<"Difference between room and server * indicates >50 ";
std::cout<<"Hour server 1 server 2 server 3 server 4 server 5 server 6 server 7 ";
for(i=0;i<nmbrOfRows;i++)
{std::cout<<i+1;
for(j=0;j<nmbrOfClmns-1;j++)
{diff=theArray[i][j]-theArray[i][NMBROFCLMNS-1];
std::cout<<" "<<diff;
if(diff>50)
std::cout<<"*";
}
std::cout<<std::endl;
}
} //end temperature Difference
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.