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
slava [35]
2 years ago
14

Write a program that uses a 2-D array to store the highest and lowest temperatures for each month of the year. The program shoul

d output the average high, average low, and highest and lowest temperatures of the year. Your program must consist of the following methods with their appropriate parameters:
Computers and Technology
1 answer:
dedylja [7]2 years ago
7 0

Answer:

*/

import java.util.*;

public class Main{

public static void main(String[] args){

 

int infoArray[][]=getData();

int avgArray[][]=average(infoArray);

int tempArray[][]=temps(infoArray);

System.out.println("Data set - Highs: 87,99,100,102,101,97,97,93,99,94,98,92.");  

System.out.println("Lows: 11,12,19,24,23,25,32,33,29,21,10,1.");

System.out.println("Average High: "+avgArray[0][0]);

System.out.println("Average Low: "+avgArray[1][0]);

System.out.println("Highest Temperature: "+tempArray[0][0]);

System.out.println("Lowest Temperature: "+tempArray[1][0]);

}

public static int[][] getData(){

 int tempDatahl[][] = {{87,99,100,102,101,97,97,93,99,94,98,92},{11,12,19,24,23,25,32,33,29,21,10,1}};

 return tempDatahl;

}

public static int[][] average(int x[][]){

int avgH = 0;

int avgL = 0;

 

//loop to find avg high

 for(int i=0;i<x[0].length;i++){

     avgH+=x[0][i]  ;

}

 

//loop to find avg low

 for(int h=0;h<x[1].length;h++){

     avgL+=x[1][h]  ;

}  

 

 avgH=avgH/x[0].length;

 avgL=avgL/x[1].length;

 

 int avgData[][] = {{avgH},{avgL}};

 return avgData;

}

public static int[][] temps(int x[][]){

 //high temp

 int ht = 0;

 int lt = 100;

 

 for(int t=0;t<x[0].length;t++){

   if(x[0][t]>ht){

     ht = x[0][t];

   }

 }

 //low temp

  for(int y=0;y<x[1].length;y++){

   if(x[1][y]<lt){

     lt = x[1][y];

   }

 }  

      int arrTemps[][]={{ht},{lt}};

     return arrTemps;

}

 

}

Explanation:

You might be interested in
What is the result when you run the following line of code after a prompt??
qwelly [4]

Answer:

The following output is 14

Explanation:

When you print something, python interprets it and spits it out to the console. In this case, python is just interpreting 3 + 11, which equals 14. Thus, making the answer 14.

hope i helped :D

3 0
2 years ago
You ping a host on the internet to check for connectivity. Your ping times out, and you get no response. What is most likely the
Reptile [31]

Answer:

It could be because you where hack. Or there was something wrong with the site that stopped it from saying why it stopped.

8 0
2 years ago
A technician is dispatch to troubleshoot a user's computer.
Margarita [4]

Answer:

All of the above.

Explanation:

Thrashing or drive or disk thrashing occurs when the hard drive is stressed with transferring information between the system memory and virtual machine excessively. In thrashing, there is a large number of processes running in the system and the system memory is too small to handle all processes. Thrashing leads to decreased system performance and hard disk failure.

To stop the impact of thrashing, install more RAM, end unimportant progam processes etc.

5 0
3 years ago
Lil fun question : burgers or pizza??
Margarita [4]
Pizza. . . . . . . . . . .
6 0
2 years ago
Read 2 more answers
Queues can be represented using linear arrays and have the variable REAR that point to the position from where insertions can be
Levart [38]

Answer:

8

Explanation:

7 0
2 years ago
Other questions:
  • Where can you check effective access on a shared folder? answer?
    11·1 answer
  • Which situation can result in positive population growth?
    14·1 answer
  • Which of these expressions evaluates to 4.0?
    12·2 answers
  • what tool can a student use to make sure his or her work paper does not take credit for someone else's work ?
    5·1 answer
  • Which option will automatically update copied data?
    12·2 answers
  • Prepare a risk assessment report (RAR) with information on the threats, vulnerabilities, likelihood of exploitation of security
    14·1 answer
  • How much a T-mobile plan cost​
    11·2 answers
  • Create a file named homework_instructions.txt using VI editor and type in it all the submission instructions from page1 of this
    7·1 answer
  • How do you initiate a sprite’s actions in a scene?
    8·1 answer
  • • Do you think documentaries are best delivered in media such as films or documentary?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!