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
Cerrena [4.2K]
3 years ago
3

Given a variable temps that refers to a list, all of whose elements refer to values of type float, representing temperature data

, compute the average temperature and assign it to a variable named avg_temp. Besides temps and avg_temp, you may use two other variables -- k and total.
Computers and Technology
1 answer:
steposvetlana [31]3 years ago
8 0

Answer:

The solution code is written in Java. This is because Java is a type-strict language that enable us to assign a specific data type (e.g. float) to the variable that match the problem scope stated in the question.

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        float temps[] = { 12.1f, 5.4f, 8.9f, 3.2f, 15.5f };
  4.        
  5.        float avg_temp;
  6.        float total = 0;
  7.        for(int k = 0; k < temps.length; k++)
  8.        {
  9.            total += temps[k];
  10.        }
  11.        avg_temp = total / temps.length;
  12.        System.out.println(avg_temp);
  13.    }
  14. }

Explanation:

Firstly, declare a temps array with float type and assigns it with a random set of temperature values (Line 5). All the random temperature are float values (decimal numbers).

Next, declare another two variables avg_temp (Line 7) and total (Line 8) with float type. The avg_temp will hold the average of  temperatures from the array whereas the total will hold the total temperatures.

Prior to calculating the average temperature, we need to get the total of temperature. This is done by creating a for-loop and iterate through each element from the array and add it to the variable total (Line 10 -13).

Once we get the total of temperature, divide the variable total with the length of the array temps (which is equivalent to the number of temperature values in the array) and assign it to variable avg_temp ( Line 15).

At last, we can print out the value of avg_temp to verify the output (Line 17).

You might be interested in
A low concentration of market power has positive affects. A low concentration of market share has which of the following effects
lisov135 [29]
A or b i think hope it helps good luck and i hope it helps
6 0
4 years ago
Edhesive assignment 4
Agata [3.3K]

Answer:

nrToCheck = int(input("How many numbers do you need to check? "))

nrEven = 0

nrOdd = 0

for i in range(nrToCheck):

 number = int(input("Enter number: "))

 if (number % 2):

   nrOdd = nrOdd + 1

   print("{} is an odd number".format(number))

 else:

   nrEven = nrEven + 1

   print("{} is an even number".format(number))

print("You entered {} even number(s).".format(nrEven));

print("You entered {} odd number(s).".format(nrOdd));

7 0
3 years ago
While a computer is running the operating system remains in memory. true or false?
MrMuchimi
While a computer is running the operating system remains in memory is true.
8 0
4 years ago
Write a set of directions that tells an operating system’s dispatcher what to do when a process time slice is over.
tatyana61 [14]
<span> Directions that tells an operating system's dispatcher what to do when a process's time slice is over.Wait for the interrupt handler to be execute. Allow the scheduler to update the process table. Select the process form the process table that has the highest priority, restart the time, and allow the selected process to begin its time slice. Directions that tells an operating system's dispatcher what to do when a process's time slice is over. Signal an interrupt, save the current position, execute the current position, execute the interrupt handler, and switch to the next process until the process or processes is complete. If a process executes an I/O request, the time slice of that process will be terminated because it would waste the remaining time waiting for the controller to perform the request. A situation in a time-sharing system in which a process does not consume the entire time slice allotted to it. Client/server model Defines the basic roles played by the processes as being that of either a client, which makes requests of other processes Components of the email address </span>
6 0
4 years ago
Read 2 more answers
Q4. What is one of the benefits of using a library in a program?
Grace [21]

Answer:

Simplifies creating a complex program

Explanation:

5 0
3 years ago
Other questions:
  • Which of the following locations is the option to show hidden files or folders location
    7·2 answers
  • A(n) ____________________ or cryptosystem is an encryption method or process encompassing the algorithm, key(s) or cryptovariabl
    11·1 answer
  • How do you get 99 points on sunny meadows simulation?
    6·2 answers
  • When RadioButton objects are contained in a group box, the user can select only one of the radio buttons on the panel.
    12·1 answer
  • A tower or mini tower pc is a type of all- in -one unit true or false
    9·2 answers
  • Which one is the answer for the question.
    11·1 answer
  • What is the role of the memory in a computer ​
    11·1 answer
  • Which of the following statements holds true for the term plug-in? Group of answer choices It refers to a program (typically a m
    11·1 answer
  • What is a trojan horse
    8·2 answers
  • If you are going to develop a special computer, what would it be and explain it's purpose.​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!