1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
inn [45]
3 years ago
14

Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The p

rogram should output the average high, average low, and the highest and lowest temperatures for the year. Your program must consist of the following functions: 1. Function getData: This function reads and stores data in the two- dimensional array. 2. Function averageHigh: This function calculates and returns the average high temperature for the year. 3. Function averageLow: This function calculates and returns the aver- age low temperature for the year. 4. Function indexHighTemp: This function returns the index of the highest high temperature in the array. 5. Function indexLowTemp: This function returns the index of the low- est low temperature in the array. These functions must all have the appropriate parameters.
Computers and Technology
1 answer:
Cerrena [4.2K]3 years ago
6 0

Answer:

#include <iostream>

#include <fstream>

#include <cstdlib>

#include <iomanip>

using namespace std;

void getData(int array [12][2], ifstream& infile);

double averageHigh (int array [12][2]);

double averageLow (int array [12][2]);

int indexHighTemp (int array [12][2], ofstream& outfile);

int indexLowTemp (int array [12][2], ofstream& outfile);

int main()

{

int array [12][2];

int high;

int low;

ifstream infile;

ofstream outfile;

infile.open("E:\\program6input.txt");

outfile.open("E:\\program6ouput.txt");

outfile << "Daniel" <<endl;

outfile<<endl;

outfile<<fixed<<showpoint<<setprecision(2);

getData(array, infile);

averageHigh(array);

outfile << setw(18) << left << "Average High Temp:" << averageHigh (array)<<endl;

averageLow (array);

outfile << setw(18) << left << "Average Low Temp:"<<averageLow (array)<<endl;

high = indexHighTemp (array, outfile);

low = indexLowTemp (array, outfile);

outfile << setw(18) << left << "Highest Temp:";

outfile << high << endl;

outfile << setw(18) << left << "Lowest Temp:";

outfile << low << endl;

infile.close();

outfile.close();

system("pause");

}

void getData (int array[12][2], ifstream& infile)

{

int x;

int y;

for(x=0; x<12; x++)

{

for(y=0; y<2; y++)

{

infile >> array[x][y];

}

}

}

double averageHigh (int array [12][2])

{

double avg;

double sum;

int x;

int y;

avg = 0;

sum = 0;

for (x = 0; x<12; x++)

{

{

sum = sum + array[x][0];

}

}

avg = sum / x;

return avg;

}

double averageLow (int array[12][2])

{

double avg2;

double sum2;

int x;

int y;

avg2=0;

sum2=0;

for (x=0; x<12; x++)

{

{

sum2 = sum2 + array[x][1];

}

}

avg2 = sum2 /x;

return avg2;

}

int indexHighTemp (int array[12][2], ofstream& outfile)

{

int highest;

int x;

int y;

int xx;

int yy;

highest = array[0][0];

for (x=0; x<12; x++)

{

for (y=0; y<2; y++)

{

if (highest < array[x][y])

{

highest =array[x][y];

xx=x;

yy=y;

}

}

}

outfile << setw(18) << left << "High Temp Index:"<< "[" << xx << ","<< yy<< "]" << endl;

return highest;

}

int indexLowTemp (int array[12][2], ofstream& outfile)

{

int lowest;

int x;

int y;

int xx;

int yy;

lowest = array[0][0];

for (x=0; x<12; x++)

{

for (y=0; y<2; y++)

{

if (lowest > array[x][y])

{

lowest = array[x][y];

xx = x;

yy = y;

}

}

}

outfile << setw(18) << left << "Low Temp Index:" << "[" << xx << "," << yy <<"]" << endl;

return lowest;

}

Explanation:

You might be interested in
What is the best java 3d modeler library?
LenaWriter [7]
I believe its "Thinking Universe"
5 0
4 years ago
A device receives a Transmission Control Protocol (TCP) packet. The device understands where the actual data payload begins. Whi
asambeis [7]

Answer:

The answer is 1. Data offset

Explanation:

From the Question given, a device that receives a Transmission Control Protocol packet and also understands where the actual data payload begins is called the Data Offset

Data offset: This is the 4 bit data offset field, also referred to as the header length. It indicates the length of the TCP header so that we know where the actual data starts from or begins.

5 0
3 years ago
How many bits are in a gigabyte in exponential form? ...?
notka56 [123]
1 gigabyte =
8000000000 bits

And exponential form is 8x10^9
8 0
4 years ago
Read 2 more answers
The flowchart that show the sequence of logical operations executed by a computer is called a: A. Systems flowchart B. Operation
Blizzard [7]

Answer:

It is called a Program Flowchart.

Explanation:

5 0
3 years ago
Find the error in the following pseudocode. Module main () Call raiseToPower (2, 1.5) End Module Module raiseToPower (Real value
Nataliya [291]

Answer:

Call raiseToPower (2, 1.5) '

or

raiseToPower (Real value, Integer power)

Explanation:

To solve this, first organize the pseudo code,

1) main ()

2) Call raiseToPower (2, 1.5)

3) End Module

4) Module

5) raiseToPower (Real value, Integer power)

6) Declare Real result

7) Set result=value^power

8) Display result

9) End Module

The first three lines in pseudo code are representing the main module. While lines 4-9 shows the definition of module that is being called in main function.  

If we look at the raiseToPower definition at line5, we can see that it is requiring any real value for the base number. However, for power, it defines only integers.

But, in the main function, 1.5 is placed as a power that is not an integer. Therefore, this is the error in pseudo code. It should be changed to any integer.

Alternatively, change the integer power to real power to avoid this error.

8 0
3 years ago
Other questions:
  • A business that subscribes to a specific computing model has its entire system fully functional within a short time. What benefi
    7·1 answer
  • What special precautions should you take when detailing a steel-framed building to avoid excessive conduction of heat through th
    9·1 answer
  • In GIMP, the ( ) displays the image that the user is currently working on
    12·1 answer
  • ​Which of the following styles sets the column breaks within paragraphs to leave a minimum of two and three lines at the top and
    11·1 answer
  • Which term describes the order of arrangement of files and folders on a computer?
    10·1 answer
  • Which step of the laser printer imaging process requires troubleshooting if a printer produces ghost images on output pages?
    13·1 answer
  • III. FILL-IN THE BLANK (five points each)
    14·1 answer
  • Biosolids are used as a chemical free natural choice for fertilizing.
    5·1 answer
  • Why would you choose a mobile device over a laptop? 1-2 sentences.
    11·1 answer
  • Give an example of how loops are used in programming Kturtle​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!