This lab was designed to teach you more about using Scanner to chop up Strings. Lab Description : Take a group of numbers all on the same line and average the numbers. First, total up all of the numbers. Then, take the total and divide that by the number of numbers. Format the average to three decimal places Sample Data : 9 10 5 20 11 22 33 44 55 66 77 4B 52 29 10D 50 29 D 100 90 95 98 100 97 Files Needed :: Average.java AverageRunner.java Sample Output: 9 10 5 20 average = 11.000 11 22 33 44 55 66 77 average = 44.000 48 52 29 100 50 29 average - 51.333 0 average - 0.000 100 90 95 98 100 97 average - 96.667

Answers

Answer 1

Answer:

The program is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

 String score;

 System.out.print("Scores: ");

 score = input.nextLine();

 String[] scores_string = score.split(" ");

 double total = 0;

 for(int i = 0; i<scores_string.length;i++){

     total+= Double.parseDouble(scores_string[i]);  }

 double average = total/scores_string.length;

 System.out.format("Average: %.3f", average); }

}

Explanation:

This declares score as string

 String score;

This prompts the user for scores

 System.out.print("Scores: ");

This gets the input from the user

 score = input.nextLine();

This splits the scores into an array

 String[] scores_string = score.split(" ");

This initializes total to 0

 double total = 0;

This iterates through the scores

 for(int i = 0; i<scores_string.length;i++){

This calculates the sum by first converting each entry to double

     total+= Double.parseDouble(scores_string[i]);  }

The average is calculated here

 double average = total/scores_string.length;

This prints the average

 System.out.format("Average: %.3f", average); }

}


Related Questions

Acróstico sobre mouse

Answers

this is a PICTURE

i HOPE IT'S HELP

Which of the following characteristics differentiates PCM from BWF audio
file formats?
metadata storage
.wav file extension
uncompressed audio file format
compressed audio file format

Answers

Answer: A

Explanation:

Answer:

A

Explanation:

Animation timing is does not affect the
speed of the presentation
Select one:
True
False​

Answers

Answer:

True

Explanation:

I think it's true.....

Suppose you are choosing between the following three algorithms:
• Algorithm A solves problems by dividing them into five subproblems of half the size, recursively solving each subproblem, and then combining the solutions in linear time.
• Algorithm B solves problems of size n by recursively solving two subproblems of size n − 1 and then combining the solutions in constant time.
• Algorithm C solves problems of size n by dividing them into nine sub-problems of size n=3, recursively solving each sub-problem, and then combining the solutions in O(n2) time.
What are the running times of each of these algorithms (in big-O notation), and which would you choose?

Answers

Answer:

Algorithm C is chosen

Explanation:

For Algorithm A

T(n) = 5 * T ( n/2 ) + 0(n)

where : a = 5 , b = 2 , ∝ = 1

attached below is the remaining part of the solution

Other Questions
1. What do producers do, and what is another name for them? Explain the relationship between mutations, adaptations,natural selection, and extinction. A new espresso coffee maker is being used at the coffee shop where you work. It heats water to 122F in a matter of seconds. What is the equivalentCelsius reading of this temperature? A rod that is 96.0 cm long is made of glass that has an index of refraction equal to 1.60. The rod has its ends ground to convex spherical surfaces that have radii equal to 8.00 cm and 19.1 cm. An object is in air on the long axis of the rod 19.9 cm from the end that has the 19.1-cm radius.(a) Find the image distance due to refraction at the 19.1-cm radius surface.(b) Find the position of the final image due to refraction at both surfaces.(c) Is the final image real or virtual? 35 POINTSS!!! PLSSSS HELLPPP!!! Work is the transfer of power from one object to another.Please select the best answer from the choices providedTF Patterson Development sometimes sells property on an installment basis. In those cases, Patterson reports income in its income statement in the year of the sale but reports installment income by the installment method on the tax return. Installment income in 2021 was $240 million, which Patterson expects to collect equally over the next four years. The tax rate is 25%, but based on an enacted law, is scheduled to become 35% in 2023. Patterson's pretax accounting income for the 2013 income statement was $530 million of this, $30 million is non-taxable revenue from proceeds of a life insurance policy. There were no differences between accounting income and taxable income other than those described above and no cumlative temporary differences existed at the beggining of the year:1. Prepare the appropriate journal entry to record patterson's 2013 income taxes. 2. What is Patterson's 2013 net income? PLEASE HELP! I'LL GIVE BRAINLEST 1. Which of the following events is not a source of genetic variation in eukaryotic organisms? J. MutationK. Independent assortmentL. MitosisM. Fertilisation We learned that the invention of television helped the fight for equality.Give me 1 Pro's and 1 Con about having the news cover the Civil rightsera.Your answer what is the definition of corresponding sides Helppppppppppp!!!!!!!!!!!!!????? I used a stick of (vegan) butter as our example of thinking about how temperature changes the properties of something when it is wamer or cooler.1. What is something else you could use to describe how temperature affects the properties of when it is warmer or cooler? How does this change whether it is warm or cold. Describe it. Escribe de nuevo las siguientes frases cambiando la expresin subrayada por la que se da entre parntesis. Recuerda cambiar el verbo a la forma correspondiente del pretrito o el imperfecto. ejemplo. l vino aqu con su computadora el otro da. l vena aqu con su computadora a menudo. (a menudo) 1. Yo lo vi ayer. (con frecuencia) 2. Carlos me repiti la misma cosa la semana pasada. (una y otra vez) 3. l nos visitaba todos los fines de semana. (el fin de semana pasado) 4. Fue una casa triste mientras estuvo en el hospital. (desde el principio) 5. Recibimos un correo de Sandra hace un mes. (todas las semanas) 6. Ellos me lo decan cada vez. (el otro da) 7. l me llam por su mvil hace una hora. (a cada hora) A mirror has a parabolic surface defined by the equation y = x with the vertex (0, 0) at the center of the mirror. When the width of the mirror is 8 inches, what is the depth, y, of the mirror?A.) in.B.) in.C.) in.D.) 2 in. Abe makes $18.50 per hour. He works 40 hours a week. He is considering renting an apartment that will cost $1,500 per month. What is the difference between his recommended rent amount and the cost of this apartment (round to the nearest dollar)? what does venerable mean Please help best gets brainlist and 5/5 and show work please Calculate the refractive index for a substance where the angle of incidence is 300 , the angle of refraction is 600 , and the refractive index of second substance is 1.5 The brain send signals that control the speed at which food moves through the digestive system. What systems are involved?A.Circulatory, Immune, digestive B.Muscular, Digestive, ImmuneC.Digestive, Muscular, Nervous D.Respiratory, Endocrine, Digestive What are 3 factors that led to the French Revolution?