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
Whitepunk [10]
3 years ago
10

Iven an array temps of double s, containing temperature data, compute the average temperature. Store the average in a variable c

alled avgTemp. Besides temps and avgTemp, you may use only two other variables -- an int variable k and a double variable named total, which have been declared .
k = 0;
total = 0;
while (k < temps.length)
{
total = total + temps[k];
k++;
}

avgTemp = total / (temps.length);
Computers and Technology
1 answer:
ale4655 [162]3 years ago
6 0

Answer:

import java.util.Arrays;

import java.util.Scanner;

public class num1 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter length of the array:");

       int len = in.nextInt();

       double [] temps = new double[len];

       double avgTem;

       int k =0;

       double total = 0;

       for( k=0; k<temps.length; k++){

           System.out.println("Enter values for the array");

           temps[k]=in.nextDouble();

       }

       System.out.println("The Arrays contains the following values");

       System.out.println(Arrays.toString(temps));

       // Computing the average of the values

       for(k=0; k<temps.length; k++){

           total = total+temps[k];

       }

       avgTem = total/(temps.length);

       System.out.println("The average Temperature is: "+avgTem);

   }

}

Explanation:

  • Using Java programming language
  • Import the Scanner class to receive user input
  • Prompt User for the length of the Array, receive and store in a variable len;
  • Declare a new double array of size len double [] temps = new double[len];
  • Using a for loop, continually prompt user to enter values into the array
  • Display the values of the array using Java's Arrays.toString method
  • Use another for loop to add up all the elements in the arraay and store in the variable called total
  • Outside the second for loop calculate the average avgTem = total/(temps.length);
  • Display the average temp.
You might be interested in
What network setting do i need for a workgroup?
juin [17]
Joining a workgroup requires setting up the PC with a workgroup name.
5 0
3 years ago
What does a companys code of ehtics cover
Stolb23 [73]
A code of ethics and professional conduct outlines the ethical principles that govern decisions and behavior at a company or organization. They give general outlines of how employees should behave, as well as specific guidance for handling issues like harassment, safety, and conflicts of interest.
4 0
2 years ago
Read 2 more answers
An ironworker standing 30 feet in the air is safe wearing a full body harness that is not tied off
Nataly_w [17]

Answer

It is FALSE .

Explanation

A full body harness is a  type of safety 'attire' specifically put on for the purposes of protection. Safety harness are necessarily for fall protection. It also provides the user or the worker comfortability and confidence while working on those high risky places. It is advisable that when a worker is exposed to a fall hazard which about six feet and above high to wear a harness that is tied off.

8 0
3 years ago
Read 2 more answers
How to Save Power-Point presentation as a single file Web page that can be uploaded to the World Wide Web ?
Fittoniya [83]
Google docs and save it there. hope this helps. thanks
3 0
3 years ago
1.where should the name of the website or company logo appear on a website
Paul [167]

Answer:

1. First Page

2. Two Colors

8 0
3 years ago
Read 2 more answers
Other questions:
  • Exposing employee and customer personal data to an untrusted environment is an example of:
    9·1 answer
  • Write the importance of cyber law? In point .<br>​
    10·2 answers
  • What is a bug?
    11·2 answers
  • When you purchase software in a box, reading the ________ is important to know if the software will function properly?
    13·1 answer
  • Which is an example of Raw Input?
    11·1 answer
  • As a general rule, the number of bullet points on a slide should not exceed _____. a.2 b.4 c.8 d.10
    9·1 answer
  • Last bittttt of points
    8·1 answer
  • Every finger has a key it should be resting on when you are not typing<br> 1. False<br> 2. True
    12·2 answers
  • In cell B20, enter a
    14·1 answer
  • Which option is an example of an algorithm that is used in daily life?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!