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
nalin [4]
2 years ago
10

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

t the user for 12 months of highest and lowest. Write two methods : one to calculate and return the average high and one to calculate and return the average low of the year. These methods MUST be your original code. Your program should output all the values in the array and then output the average high and the average low.a) Function getData: This function reads and stores data in the two-dimensional array.
b) Function averageHigh: This function calculates and returns the average high temperature for the year.
c) Function averageLow: This function calculates and returns the average low temperature for the year.
d) Function indexHighTemp: This function returns the index of the highest high temperature in the array.
e) Function indexLowTemp: This function returns the index of the lowest low temperature in the array."
Computers and Technology
1 answer:
steposvetlana [31]2 years ago
7 0

Answer:

The Java code is given below with appropriate comments

Explanation:

import java.util.Scanner;

public class Temperature {

 

  public static void main(String[] args)

  {

      // declaring the temperatures array

      double[] maxTemp = new double[12];

      double[] lowTemp = new double[12];

      double avgHighTemp = 0;

      double avgLowTemp = 0;

     

      Scanner kb = new Scanner(System.in);

      System.out.println("Please enter the highest and lowest temperatures");

      System.out.println("of each month one by one below\n");

     

      // inputting the temperatures one by one

      for(int i = 0; i < 12; i++)

      {

          System.out.print("Please enter the highest temperature for month #" + (i+1) + ": ");

          maxTemp[i] = Integer.parseInt(kb.nextLine());

          System.out.print("Please enter the lowest temperature for month #" + (i+1) + ": ");

          lowTemp[i] = Integer.parseInt(kb.nextLine());

          System.out.println();

      }

      avgHighTemp = getAvgHighTemperature(maxTemp);

      avgLowTemp = getAvgLowTemperature(lowTemp);

      System.out.printf("Average high temperature is: %.2f\n", avgHighTemp);

      System.out.printf("Average low temperature is: %.2f\n", avgLowTemp);

     

  }

 

  // method to calculate the average high temperature

  public static double getAvgHighTemperature(double[] highTemp)

  {

      double total = 0;

      for(int i = 0; i < 12; i++)

      {

          total += highTemp[i];

      }

      return total/12;

  }

 

  // method to calculate the average low temperature

  public static double getAvgLowTemperature(double[] lowTemp)

  {

      double total = 0;

      for(int i = 0; i < 12; i++)

      {

          total += lowTemp[i];

      }

      return total/12;

  }

}

You might be interested in
Your neighbor has moved to another country. He informs you about his new job. You wantto congratulate him by sending an e-mail m
Licemer1 [7]

Answer:

C. Modem

Explanation:

According to my research on information technology, I can say that based on the information provided within the question you must connect your computer to a Modem in order to provide your computer with an internet connection. A modem is a hardware device that converts data into a format that can be transmitted from computer to computer which is basically what the internet is

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

3 0
3 years ago
There are ___ Federal Reserve Banks. Each bank is also in charge of its assigned District Banks.
s344n2d4d5 [400]
B. 12

There are 12 Federal Reserve Banks. Each bank is also in charge of its assigned District Banks.

6 0
2 years ago
Help me. thank you very much
Scilla [17]

Answer:

3425236235623523334252362356235233342523623562352333425236235623523334252362356235233362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252363623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523636235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252363623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523636235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252363623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523636235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252363623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233  5623523334252362356235233342523636235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252363425236235623523334252362356235233342523623562352332

Explanation:

342523623562352333425236235623523334252362356235233342523 6235233342523636235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425 5236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252363623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523636235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252363623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233342523623562352333425236235623523334252362356235233

4 0
2 years ago
When spraying pesticide wear and protective eyeglass​
exis [7]
Ummmmmmmmmmmmmmmmmmmmm ok
6 0
2 years ago
Read 2 more answers
O How basic blocks are identified and how the blocks are used to construct control flow graphs
OLEGan [10]

Basic blocks are identified  because they are known to be a straight line that is known also as a code sequence that tends to have no branches in regards to its in and out branches and its exception is only to the entry and at the end.

Note that  Basic Block is said to be a composition  of statements that is known to be one that often always executes one after other, and this is often done in a sequence.

<h3>How do you create a flow graph from the basic blocks?</h3>

Flow graph  is gotten by:

  • Lets Block B1 be the initial node and also Block B2 will tend to follows B1, so from B2 to B1 there is seen a kind of an edge.

Note that the first task is for a person to partition a sequence of three-address code and this is done into basic blocks.

Hence, Basic blocks are identified  because they are known to be a straight line that is known also as a code sequence that tends to have no branches in regards to its in and out branches and its exception is only to the entry and at the end.

Learn more about basic blocks from

brainly.com/question/132319

#SPJ1

5 0
1 year ago
Other questions:
  • In this code, identify the repeated pattern and replace it with a function called month_days, that receives the name of the mont
    14·1 answer
  • All of the following statements correctly describe an advantage or disadvantage associated with the use of Monte Carlo Analysis
    9·1 answer
  • A firewall, when properly implemented, can prevent most attacks on your system.
    11·1 answer
  • Investments in data networks, ip addresses, routers, and switches are ________ because of their impact on productivity, security
    14·1 answer
  • A specialized security administrator responsible for performing systems development life cycle (SDLC) activities in the developm
    11·1 answer
  • From the Software Engineering Code of Ethics, which clauses relate to intellectual property (check all that apply)
    15·1 answer
  • Which of the following is NOT true about procedural abstraction?
    9·1 answer
  • "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequen
    10·2 answers
  • GRAND THEFT AUTO 5 LOLLL
    15·2 answers
  • Write a function named swapFrontBack that takes as input a vector of integers. The function should swap the first element in the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!