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]
3 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]3 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
a third important logical element is the inverter. an inverter does pretty much what it says. if the input is 0, the output is 1
Mrrafil [7]

Answer:

xy225.252 <  \geqslant  > . \times 5 \times . =  {?}^{2}

7 0
3 years ago
Write a program to test the various operations of the class clockType
Umnica [9.8K]
The class clock type was designed to implement the time of day in a program. Certain applications, and additions to hours, minutes, and seconds, might require you to start at the time zone.
5 0
3 years ago
​Which SQL keyword is used to search for records?
Over [174]
SQL (<span>Structured Query Language.) is the standard programming language for communicating and organizing databases (DB).
In order to search through the database the statement SELECT should be used.
SELECT select data from the database.
SELECT is followed by the statement FROM which defines from which database you search record. </span>
8 0
3 years ago
Which of the following is NOT one of the three basic structures used to solved logical problems?
Oliga [24]
I think module is not one of the theee basic structure
8 0
3 years ago
When using the text command, what needs to be around the word or words you<br> want to appear?
AysviL [449]

Answer:

In most programming languages "" are required around text.

Explanation:

Python: print("text")

HTML: <p>text</p>

C++: int Main() {

cout << "text" << endl;

}

Lua: print("text")

8 0
3 years ago
Other questions:
  • How do you think your ability to work might be affected if you don’t magnify a document so that text is at a size for you to rea
    9·1 answer
  • When you declare a string data type, you are actually creating an object from the?
    5·1 answer
  • Which one of these do not belong on the Do's list in Helpful Hints when preparing a presentation: Which one of these do not belo
    8·1 answer
  • Peter has recently bought a media player and a digital camera he wants to buy a memory card and then use devices which memory do
    11·2 answers
  • Compare the applications below:
    10·2 answers
  • Modify class Time2 of fig 8.5, (which is split into four pictures) to include a tick method that increments the time stored in a
    8·1 answer
  • Write a class called Person that has two data members - the person's name and age. It should have an init method that takes two
    12·1 answer
  • 6.An organization wants to implement a remote dial-in server to ensure that personnel can connect to the organization's network
    11·1 answer
  • Which of the following is a productivity strategy for collaboration?
    9·1 answer
  • Jim is working on a network design for a small office running a Windows file and printer server with Internet
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!