import java.util.Scanner; /* * This program reads double values from a list (actually a string) using a
Question:
import java.util.Scanner;
/*
* This program reads double values from a list (actually a string) using a scanner. It calculates the average of these values as
* well as the minimum value and the maximum value
* For example, if the values are: 20 10 30 40 then the average is (20+10+30+40)/4 = 25 and the min is 10 and the max is 40
*/
public class SequenceOfValues
{
public static void main(String[] args)
{
String numbers = "34 68 22 76.0 81 98 78 84 62";
Scanner in = new Scanner(numbers);
boolean first = true;
double min = 0;
double max = 0;
double sum = 0.0;
// Use this variable to keep track of the number of floating point numbers read in from numbers
int numberOfValuesSeen = 0;
//-----------Start below here. To do: approximate lines of code = 14
// Use a while loop and read one number at a time using the scanner. Inside the loop, update variable sum and update variables min and max if necessary
// Don't forget to increment variable numberOfValuesSeen
// Use the boolean variable first (declared above) to determine if this is the first time through the loop.
// If so, set sum, min, max to the first value read from the scanner and set first to false
// Hint: never call in.nextDouble() more than once inside a loop - call it and assign the result to a variable. Use this variable to test the value