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
Is it possible to have a deadlock involving only oneprocess? Explain your answer.
Aleonysh [2.5K]

Answer:

Hi!

It is not possible to have a deadlock involving only one process.

Explanation:

Deadlock is only possible if there are multiple processes trying to access the same shared resources. Another way to see it is if you have shared resources only can be a deadlock if multiple processes attempt to use it.

With only one process, you can use shared resources without the risk of fall into deadlock, but you don't have concurrence either.

4 0
3 years ago
Create a query that shows columns employee last name, job title and hire date for those employees who joined the company on or a
yawa3891 [41]

Answer:

SELECT last_name, job_title, hire_date FROM employee WHERE hire_date>="01-12-2016" AND job_title != "STOCK CLERK" ORDER BY job_title DESC;

Explanation:

The SQL code queries the employee table returning records of the last_name, job_title, and hire_date columns matching the employees hired on or after December 2016 and job titles that are not stock clerks in the employee table.

The WHERE and AND clause is responsible for the condition while the ORDER BY clause returns the query result in the of the job title in descending order.

3 0
2 years ago
Which of the following conditions will maximize the amount of interest you earn
choli [55]
The answer is the amount of money you put in it, brainliest please.
4 0
2 years ago
What is the usual price of smartphone apps?
natka813 [3]

0-20 dollars

that's the usual cost for apps

and for phone it's cost

RS 32,000 Nepali rupes

you can convert it by dividing it by 110

and you will get price in dollars

8 0
2 years ago
Read 2 more answers
You have two microservices that need to communicate with each other without holding up a thread on either end. One service will
Yakvenalex [24]

Answer: E. Use a RESTful architecture for both, send the ID through a POST, and ping the service with a GET until a response is available.

Explanation:

Since there are two microservices that need to communicate with each other without holding up a thread on either end, the communication framework should be used is a RESTful architecture for both, send the ID through a POST, and ping the service with a GET until a response is available.

REST is a software architectural style which is used in defining the set of rules that be used for the creation of web services. The REST architecture allows requesting systems to be able to access and manipulate web resources.

8 0
2 years ago
Other questions:
  • Which precaution should be taken when working inside computer systems??
    9·1 answer
  • What are two names for the database that holds digital signatures provided by os manufacturers, such as microsoft and red hat?
    6·1 answer
  • What is a collection of computer programs that administer the hardware and software of a computer so that they work properly?
    7·1 answer
  • All health information available on the internet is valid. <br> a. true <br> b. false
    6·1 answer
  • If there are 18 people in your class and you want to divide the class into programming teams of 3
    7·1 answer
  • Design the following webpage using suitable html code .
    11·2 answers
  • Users can customize their Windows device by going to the Control Panel under __________.
    15·2 answers
  • Choose all that apply.
    5·2 answers
  • What is the meaning of s used in 0 and 1 in computer .​
    8·1 answer
  • Question #1
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!