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
What does the abbreviation BBC stands for?
kati45 [8]

Answer:

British Broadcasting Corporation Microcomputer System

Explanation:

The British Broadcasting Corporation Microcomputer System, or BBC Micro, is a series of microcomputers and associated peripherals designed and built by the Acorn Computer company in the 1980s for the BBC Computer Literacy Project.

4 0
3 years ago
Read 2 more answers
How can you minimize a bad background? In other words, how can you make less of a bad background show up in the photo?
Aneli [31]
What you want to do is create a shallow depth of field, this is to make your background blur and focus more on the subject. Set a large aperture, which is a low f-number, around f/1.8 or f/2 and then take a few test shots to see if this is what you would like. If you want everything to be focused in frame just do the opposite.
6 0
3 years ago
Consumer protection laws are meant to
lord [1]
B) prevent unfair or deceptive business practices.
5 0
3 years ago
PART ONE: For this assignment, create an html page that has a login form. The form should have 3 input elements -- 1. type text
Digiron [165]

Answer:

The following code are in HTML language:

Login_page.html :

<!DOCTYPE html>

<html lang="en">

<head>

<title>Login_Form</title>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="css/style.css" rel="stylesheet">

</head>

<body>

<form action="Login_page.php" method="post">

<table>

<tr>

<td>UserName</td>

<td>

<input type="text" name="username" placeholder="Username"/>

</td>

</tr>

<tr>

<td>Password</td>

<td>

<input type="password" name="password" placeholder="Password"/>

</td>

</tr>

<tr>

<td>

<input type="Submit" name="login" value="submit"/>

</td>

</tr>

</table>

</form>

</body>

</html>  

Explanation:

Here, we have to use the HTML tag, and HEAD tag and the TITLE tag for the title of the page.

Then, we have to create a table for the structure of Form page by using table tag.  

Then, we have to create form by using Form tag

Then, create two text boxes for the username and the password with the use of an input tag.

Then, we have to create a submit button for submitting the following details with the use of an input tag.

3 0
3 years ago
What is wrong with the following program? #include //Line 1 namespace aaa //Line 2 { const int X = 0; //Line 3 double y; //Line
Nataly [62]

Answer:

#include //Line 1

namespace aaa //Line 2

{ const int X = 0; //Line 3

double y; //Line 4

}

using namespace std; //Line 5

int main() //Line 6

{ y = 34.50; //Line 7

cout << "X = " << X << ", y = " << y << endl; //Line 8

return 0; //Line 9

}

In Line 1, No header file is present,so it will print output as cout and endl is not defined.

we should include <iostream> header file in line 1  

Lines 7 and 8 are incorrect.

X and y variables in aaa namespace are stated. So we can't use it any other namespace(std), but here y is initialized to 34.50 and x is printed in other namespace rather than stated.

3 0
3 years ago
Other questions:
  • Which if the following is an example of tangible property?
    7·1 answer
  • Write a function namedadd_complex that adds the correspondingnumbers of its arguments (both complexstructures), then returns the
    5·1 answer
  • A result of the Gibbons v. Ogden (1824) decision was that states​
    11·1 answer
  • I NEED SOME MAJOR HELP W/ THIS!!! PLSSS. WHOEVER HELPS GETS 80 POINTS!!! I NEED IT DONE SOON! TYY &lt;3;)
    13·1 answer
  • Which term describes a process by which malicious code can enter from a non-secure network, and make a hairpin, or sharp turn, a
    6·1 answer
  • Which relationship is possible when two tables share the same primary key?
    9·1 answer
  • I have put the question in twice and I cannot get a answer for it .. this site isn’t great in my view..
    9·1 answer
  • The memory management layer is the part of the kernel that serves out all memory allocation requests.
    8·1 answer
  • Help please i will give Brainliest
    7·1 answer
  • Which type of wireless attack is designed to capture wireless transmissions coming from legitimate users
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!