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
How does form get its power natural gas
lana [24]

Answer:

because it does

Explanation:

7 0
2 years ago
What is the difference between business strategies and business models?
bogdanovich [222]

Answer:

A . Business strategies include long-term business plans, while business models include plans for daily business functions

7 0
2 years ago
1. image-editing software
Snezhnost [94]
  • PDF:-Portable Document Format
  • Database software:-software that organizes a collection of information
  • image-editing software :-software used to enhance photographs
  • presentation software :-software used to create a slide show
  • CAD:-software used to create technical drawings.

Done

8 0
2 years ago
45 points pls help
Artemon [7]

Answer:

Repetition.

Explanation:

hope it helps u

can u mark me as brainliest

8 0
2 years ago
Read 2 more answers
SOMEONE HELP PLEASE ​
exis [7]
Do what?? please tell me
3 0
2 years ago
Other questions:
  • What standard linux utility is used to install and configure software on centos operating systems?
    8·1 answer
  • Which of the following is considered information?
    6·2 answers
  • Using computer software, compare the 2016 year-to-date sales through February to the 2017 year-to-date sales through February fo
    15·1 answer
  • Which statement accurately describes DTP programs?
    11·1 answer
  • You are a network technician for a small corporate network. It's been decided that the office needs a wireless network for emplo
    6·1 answer
  • When you're working on an image, it's a good idea to make a ____________ of the image, so that you'll have the original image in
    12·2 answers
  • How do you respond to an email?
    6·1 answer
  • What is the different between information and data
    9·1 answer
  • What does the statement that follows do? double gallons[6] = { 12.75, 14.87 }; a. It assigns the two values in the initializatio
    13·1 answer
  • Henry wants to create a presentation for his clients. He wants to upload the presentation file directly to the Internet. Which p
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!