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]
3 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]3 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
Multiple Choice
anygoal [31]

Answer:

cyptographically

Explanation:

Did this question and got it right. Good luck!

6 0
2 years ago
Which of the following commands should you use to determine whether there are any shared resources on a Windows computer with th
Law Incorporation [45]

Answer:

c. nbtstat -a 193.145.85.202

Explanation:

Nbtstat is a TCP/IP utility which is used to display the current connections and statistics of TCP/IP using NetBIOS over TCP/IP (NetBT).

It is installed on a computer running Microsoft Windows when the TCP/IP protocol stack is installed.

Also, it is very useful when we want to troubleshoot NetBIOS name resolution problems.

One can run nbtstat -a < ComputerName > to obtain the local NetBIOS name table on <ComputerName> and its MAC address

7 0
3 years ago
Read 2 more answers
An IT specialist is consulted about setting up a peer-to-peer network. What would the specialist say about security risk in this
ohaa [14]

I just did this, its A

6 0
3 years ago
Read 2 more answers
Which function converts the users input to a number without a decimal?
sertanlavr [38]

Answer:

Explanation: integer is the meaning of int() if you payed attention to programming class, int() would be a WHOLE number and not a decimal number, 2nd of all, a decimal number would be float() so the answer is int() hope i helped!

Explanation:

hope this helped byyyyyyyyyyye

6 0
3 years ago
Consider the following code: x=random.randint (1, 100) The randint is a ____.​
Mrrafil [7]
Random integer, in this case betweeen 1 and 100
5 0
3 years ago
Other questions:
  • Are there protections for people in terms of what data can be collected by different sites?
    10·1 answer
  • 1. Why is it important to compare features of a computer before making a purchase?
    13·2 answers
  • Do Violent Video Games Make People More violent in Real Life ?
    14·1 answer
  • Which statement describes what happens if multiple users make changes simultaneously to a presentation when
    10·1 answer
  • You run the ipconfig command on your computer, and it reports an IP address of 169.254.75.10 on the Ethernet interface. Which de
    8·1 answer
  • Select the correct answer.
    10·2 answers
  • Write a SELECT statement that returns three columns: EmailAddress, OrderID, and the order total for each customer. To do this, y
    14·1 answer
  • Differentiate between tabular and column form layout​
    14·1 answer
  • Explain ,how the computer network reduces cost of operation? (don't copy from any website)​
    14·1 answer
  • G i r l s o n l y j o i n <br> id= ons jcuv jke
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!