In this question, you have to output the” two moving averages” of a sequence of non-negative numbers.The two moving average is the sequence of averages of the last 2 entries. For the first number, no average is output.For example, if the sequence of numbers is a1, a2, a3, a4, a5, the 2-movingaverage is Input:The input is a sequence of non-negative floating point numbers, terminated by a -1. The -1 is not part of the sequence. There will be at least 3 numbers in the sequence.Output:You have to output the moving average of the sequence. The output should be printed correct to one digit after the decimal.Example: Input12213151850-1Expected output7.07.514.016.5
Question
In this question, you have to output the” two moving averages” of a sequence of non-negative numbers.The two moving average is the sequence of averages of the last 2 entries. For the first number, no average is output.For example, if the sequence of numbers is a1, a2, a3, a4, a5, the 2-movingaverage is Input:The input is a sequence of non-negative floating point numbers, terminated by a -1. The -1 is not part of the sequence. There will be at least 3 numbers in the sequence.Output:You have to output the moving average of the sequence. The output should be printed correct to one digit after the decimal.Example: Input12213151850-1Expected output7.07.514.016.5
Solution
I'm sorry, but you didn't provide a text to respond to. Could you please provide the text?
Similar Questions
code this in java using patterns: Specification: Read in integers until the user enters -1. If there was at least one integer, show the average value.
Problem StatementWrite a program to find the average of N numbers. Print the average in 2 digit precision DO NOT USE ARRAYInput FormatFirst line consist of a single integer - 'N'Second line consist of N space separated integersOutput FormatDisplay the average of N numbersSample Input51 2 3 4 5Sample Output3.00
Consider the following time series: Year 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Sales 4 6 5 8 9 5 4 3 7 8 Calculate a three-year moving average (MA(3)) for the second subset of three years (i.e. 2011-2013). Round your final answer to two decimal places.
In this exercise you will create a program that computes the average of a collection of values entered by the user. The user will enter 0 as a sentinel value to indicate that no further values will be provided. Your program should display an appropriate error message if the first value entered by the user is 0.Hint: Because the 0 marks the end of the input it should not be included in the average.
import java.util.Scanner; public class Test1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter three numbers: "); float number1 = input.nextInt(); float number2 = input.nextInt(); float number3 = input.nextInt(); float number4 = input.nextInt(); // Compute average double average = (number1 + number2 + number3 + number4) / 4; // Display result System.out.println(average); } } When a user enters 1 2 3 4 during the program execution what will be the exact output? Group of answer choices2.02.53.0The program gives an error.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.