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
Which two statements are true about algorithms?
DENIUS [597]

Answer:

I. Algorithms can be written using pseudocode.

II. Algorithms can be visualized using flowcharts.

Explanation:

An algorithm can be defined as a standard formula or procedures which comprises of set of finite steps or instructions for solving a problem on a computer. The time complexity is a measure of the amount of time required by an algorithm to run till its completion of the task with respect to the length of the input.

The two statements which are true about algorithms are;

I. Algorithms can be written using pseudocode. A pseudocode refers to the description of the steps contained in an algorithm using a plain or natural language.

II. Algorithms can be visualized using flowcharts. A flowchart can be defined as a graphical representation of an algorithm for a process or workflow.

Basically, a flowchart make use of standard symbols such as arrows, rectangle, diamond and an oval to graphically represent the steps associated with a system, process or workflow sequentially i.e from the beginning (start) to the end (finish).

3 0
3 years ago
Read 2 more answers
Exampels of semantic tags ?​
spayn [35]
A semantic element clearly describes its meaning to both the browser and the developer.Examples of non-semantic elements: and <span> - Tells nothing about its content. Examples of semantic elements: ,, and - Clearly defines its content.</span>
4 0
3 years ago
The valid call to the function installApplication is
Zanzabum

Answer:

B. installApplication(‘A’, 1);

Explanation:

Given

The above code segment

Required

The correct call to installApplication

The function installApplication is declared as void, meaning that it is not expected to return anything.

Also, it receives a character and an integer argument.

So, the call to this function must include a character and an integer argument, in that order.

Option D is incorrect because both arguments are integer

Option C is incorrect because it passes no argument to the function.

Option A is incorrect because it receives an integer value from the function (and the function is not meant not to have a return value).

Option B is correct

8 0
3 years ago
Select the item that best represents technology transfer?
zubka84 [21]

Answer:

Printing Press

Explanation:

Technology transfer is the simple process of sharing or dissemination of information from person to person (or from one organisation to another)

Therefore, the item that best represents technology transfer from the given answer choices is the printing press.

This is because, the printing press helped to print paper containing information which was sent from one location to another.

5 0
2 years ago
____ of risk is the choice to do nothing to protect an information asset and to accept the outcome of its potential exploitation
umka21 [38]

Answer:

b. Acceptance

Explanation:

<em>"Acceptance </em><em>of risk is the choice to do nothing to protect an information asset and to accept the outcome of its potential exploitation.  </em><em>"</em>

<em>Acceptance Control </em>is important as a strategy when an organization has accomplished a determined level of risk, or it has estimated potential damages that might happen due to attacks, or the organization has developed a thorough analysis related to cost benefits, or it has also evaluated the probabilities of attacks.

7 0
2 years ago
Other questions:
  • Which social networking function came first?
    9·2 answers
  • In this assignment, you are going to add conditional formatting to the spreadsheet you used in the previous
    13·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 38 then the outpu
    11·1 answer
  • Drag each tile to the correct box.
    9·1 answer
  • Caroline is building an expert system for wartime defense. Which of these is true about the system she is building?
    14·1 answer
  • Write Tic tac toe program in python for beginners pls
    10·1 answer
  • Which of the following tools helps ensure your document will open in older versions of word
    13·1 answer
  • Hi, I am from India. Our brainly platform isn't so good, many of 'em keep spamming questions that I ask. US platform seems much
    9·1 answer
  • You're making great progress on your assignment. You've defined the purpose of your message, identified both the primary and sec
    9·1 answer
  • A machine that converts energy to useful work.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!