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
Assume that a file contains students' ids, full names, and their scores (Assignments grade, quizzes grade,
elixir [45]

Answer:

اope its heمحبعم

Explanation:

3 0
3 years ago
I am doing keyboarding keyboarding is very boring and yeah
Bingel [31]

Answer:

yes I agree with you

Explanation:

I have been keyboarding for the past 7 hours.

7 0
2 years ago
Read 2 more answers
This is an example of what type of formula?
Dimas [21]

Answer:

Subtraction

Explanation:

That is subtracting the values of two cells.

You know because of the "-" sign

4 0
2 years ago
Four reasons why computers are powerful
zlopas [31]

Answer:

You could search up almost anything you want

they have a lot of storage

you can find good information

they help you with a lot of things

Explanation:

also how they can process information in seconds

4 0
3 years ago
PP 11.1 – Write a program that creates an exception class called StringTooLongException, designed to be thrown when a string is
Scrat [10]

Answer

The answer and procedures of the exercise are attached in the following archives.

Step-by-step explanation:

You will find the procedures, formulas or necessary explanations in the archive attached below. If you have any question ask and I will aclare your doubts kindly.  

6 0
3 years ago
Other questions:
  • Translation of a file into a coded format that occupies less space than the original file is called
    15·1 answer
  • A(n) ____________________ is hardware or software that blocks or allows transmission of information packets based on criteria su
    13·1 answer
  • How many passes will it take to find the five in this list?
    14·2 answers
  • Which of the following statements best reflects the pros and cons of overtime potential for a line installer or repairer?
    15·1 answer
  • HELP ME PLZZZ I'll give brainist​
    9·1 answer
  • 3. Special keys labelled Fl to F12.
    8·1 answer
  • Which of the following statements is correct? User data cannot be combined and shared among authorized users. In a nondatabase,
    6·1 answer
  • You've just finished installing a wireless access point for a client. What should you do to prevent unauthorized users from usin
    15·1 answer
  • View One | View All
    10·1 answer
  • What do we call notes in computer code for the programmer that are ignored by the compiler?.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!