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
Prompt the user for a string that contains two strings separated by a comma. (1 pt)Examples of strings that can be accepted:Jill
Veronika [31]

Answer:

import java.util.Scanner;

public class ParseStrings {

public static void main(String[] args) {

/* Type your code here. */

Scanner sc= new Scanner(System.in);//to read inout from user

String sentence;//to hold user input

System.out.println("Enter input string");//asking user to input string reading into sentence

sentence=sc.nextLine();

while(!sentence.equals("q"))//continues untill user enters q

{

while(!sentence.contains(","))//loop ti eport error and continue till user enters valid string

{

System.out.println("No comma in string");

System.out.println("Enter input string");

sentence=sc.nextLine();

}

//extracting words from senetnece

String word1=sentence.substring(0, sentence.indexOf(',')).trim();

String word2=sentence.substring(sentence.indexOf(',')+1).trim();

System.out.println("First word:"+word1);

System.out.println("Second word:"+word2);

System.out.println("Enter input string");//asking user to input string reading into sentence

sentence=sc.nextLine();

}

 

return;

}

}

Explanation:

7 0
3 years ago
Every time I try to look up anything on my laptop it keeps saying my connection is not priavte what do I do
dangina [55]

You can click "Advanced" and still proceed to the website.


Please mark this answer as the Brainliest! Thank you :)




6 0
3 years ago
Read 2 more answers
You are part of the team assigned to implement new software at XYZ Inc. The employees at XYZ Inc. trust the results obtained fro
Ad libitum [116K]

There are different kinds of software implementation strategy. The software implementation strategy would you recommend in this situation to allow users fall-back access to the old system as the new one is implemented is parallel start up.

  • Parallel running often called parallel start up strategy for system changeover where a new system slowly takes over the roles of the older system even when both systems operate.

This conversion often occur when the technology of the old system is outdated and as such a new system is needed to be installed to replace the old one.

The parallel running phase is the act of changing a fragment of business information technology operation to a new system.

Learn more about Parallel start up from

brainly.com/question/9343211

7 0
2 years ago
What was the best Metal Gear Solid you enjoyed the most?​
kenny6666 [7]

My personal favorite is Metal gear solid 3: <em>Snake eater</em>.

7 0
3 years ago
Identify tags and attributes in HTML 5
Vaselesa [24]

Answer:

Tags can be identified as they are written as <tagname> Something </tagname>

<tagname> this tag is called start tag.

</tagname> this tag is called as end tag.

for ex:<p> This is a paragraph </p>

There are some elements with no end tag.for ex:- <br> tag.

Attributes are used to provide additional information to an HTML element.

Every element can have attributes.

for Ex:- <h1 style="background-color:red";>MY WEBSITE </h1>

So the background of h1 will become red.

7 0
3 years ago
Other questions:
  • Select the correct answer.
    8·2 answers
  • Which action is LEAST important to maintaining a healthy credit score?
    8·2 answers
  • Match the items.
    15·1 answer
  • bj;ljfg'cfmb dfl kbslf jflk[gkdblkfd lbrkjlfbbfkjbdfjkbadbjbbkvbk'lbk'blbf;l;lkb lm;flklmkjlvkljvkljvbfbdsjsfbbjjlkbfjklbkfj'lgg
    9·2 answers
  • How much electricity is in the human brain? ​
    8·2 answers
  • The CUSTOMERS and SALES tables contain these columns:
    6·1 answer
  • 7.5 Code practice Plz answer ASAP
    15·1 answer
  • Why do people make Among Us games on Ro-blox, and thousands of people play them, when Among Us is free on all devises?
    10·1 answer
  • Bryan's company is new and has limited funds to work with. He has been tasked with finding a telecommunications technology that
    7·1 answer
  • What is the shortcut key to create a new desktop ​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!