Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. Prompt 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."

Answers

Answer 1
Answer:

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;

  }

}


Related Questions

All of the following are strengths of the Internet as a source of information except
Question 4(10pt): sum of the max value found in each row Write a function maxSum that takes two parameters; a 2D integer array with 10 columns, and the number of rows. The function must return the sum of the maximum value from each row.
When forced distribution is used to reduce leniency bias, this can cause __________ if a pfp system is in place?
Give the one simple program using c++programming language​
Which items are placed at the end of adocumentO HeaderO FooterO Foot NoteO End note​

(Numerical Data Representation) How many bits per word are required to represent the following positive decimal integers: a.0 through 100b.0 through 255c.0 through 256d.0 through 10,000,000

Answers

Answer:

a. 7 bits

b. 8 bits

c. 9 bits

d. 24 bits

Explanation:

Required

Number of bits per word

The formula to get the number of bits per word is:

2^n = N

Where

n = bits

N = numbers

Solving (a) 0 to 100

There are 101 digits between 0 and 100 (inclusive)

So:

N = 101

Substitute 101 for N in 2^n = N

2^n = 101

101 can not be expressed as an exponent of 2.

So, we substitute 101 for the closest number greater than 101 that can be expressed as an exponent of 2.

So:

2^n = 128

Express 128 as an exponent of 2

2^n = 2^7

Apply law of indices

n = 7

Hence, 7 bits are required

Solving (b): 0 through 255

There are 256 digits between 0 and 255 (inclusive)

So:

N = 256

Substitute 256 for N in 2^n = N

2^n = 256

Express 256 as an exponent of 2

2^n = 2^8

Apply law of indices

n = 8

Hence, 8 bits are required

Solving (c): 0 through 256

There are 257 digits between 0 and 256 (inclusive)

So:

N = 257

Substitute 257 for N in 2^n = N

2^n = 257

257 can not be expressed as an exponent of 2.

So, we substitute 257 for the closest number greater than 101 that can be expressed as an exponent of 2.

So:

2^n = 512

Express 512 as an exponent of 2

2^n = 2^9

Apply law of indices

n = 9

Hence, 9 bits are required

Solving (d): 0 through 10000000

There are 10000001 digits between 0 and 10000000 (inclusive)

So:

N = 10000000

Substitute 10000000 for N in 2^n = N

2^n = 10000000

10000000 can not be expressed as an exponent of 2.

So, we substitute 10000000 for the closest number greater than 101 that can be expressed as an exponent of 2.

So:

2^n = 16777216

Express 16777216  as an exponent of 2

2^n = 2^{24

Apply law of indices

n = 24

Hence, 24 bits are required

Which tool, Wireshark or NetWitness, provides information about the wireless antenna strength during a captured transmission?

Answers

Answer:

Wireshark.

Explanation:

Wireshark is a free and open source network packet sniffing tool, used for analysing, troubleshooting, software and communication protocol development etc.

It uses various extensions to capture wireless and cabled connections like AirPcap (air packet capture), pcapng ( packet capture next generation.

It uses the device's antenna to capture wireless communication and gives the signal strength, noise ratio and other information of the antenna.

You are an administrator for the Contoso Corporation. You have client software that receives its configuration from a shared folder. Therefore, you need to make sure that this shared folder is highly available. Since is used by hundreds of users, many at the same time, you want to make sure that performance is high. What would you do

Answers

In order to make sure that the shared folder is accessible and the performance is high at all times, it would be best to house it on a secure file sharing/storage services, such as Box or Dropbox.

What type of result does the MATCH function, when used on its own, return?

Answers

Answer:

It returns the lookup value located in a specific location.

Explanation:

Describe the components of Computer-based informationsystems.

Answers

Answer: Major components of a computer based information system:-

  • Hardware
  • Software
  • Network
  • Databases

Explanation: The basic components of a computer based information system are :

  • Hardware -devices that physical parts of a computer system such as monitor, printer,keyboard etc.
  • Software- they are form of programs that perform the processing of the data .
  • Networks- is the phase in which multiple computer system are connected with each other and share resources.
  • Databases- they are collection of the information or related data in the forms of files or tables.

Suppose an array with six rows and eight columns is stored in row major order starting at address 20 (base 10). If each entry in the array requires only one memory cell, what is the address of the entry in the third row and fourth column?

Answers

Answer:

39

Explanation:

Since each of the address occupies only 1 memory cell and the 2-D array is row-major 2-D array.So the elements will be filled row wise.First the first row will be fully filled after that second row and so on.Since we want the address of the element at third row and fourth column.

we can generalize this :

address of the element at ith row and jth column=s + ( c * ( i - 1 ) + ( j - 1 ) ).

s=Starting address.

c=Number of columns in the 2-D array.

address=20+(8*(3-1)+(4-1))

=20+(8*2+3)

=20+16+3

=39

Or you can make a matrix of six rows and eight columns and put first cell with 20.Start filling the elements row wise one by one and look what is the count of 3rd row and 4th column.