The problem
An audio signal is sometimes stored as a list of int values. The values represent the intensity of the signal at successive time intervals. In a program these will be stored as an array.
Often a small amount of noise is included in the signal. Noise is usually small, momentary changes in the signal level. An example is the static that is heard in addition to the signal in AM radio. Smoothing the signal removes some of the noise and improves the quality of the signal. This homework is to smooth the values in an integer array.
Say that the original values are in the array “signal”. Compute the smoothed signals as follows:

each value smooth[N] is the average of signal[N-1], signal[N], signal[N+1]
for the first element of smooth, average the first two elements of signal.
for the last element of smooth average the last two elements of signal.

Use integer arithmetic for this so that the vales in smooth are integers.
Guidance
Your program should first of all ask the user to enter the number of signals to be processed. Input using a JOptionPane.

Provided the number of signals is greater than 2 the program will then ask the user to enter the signals. Input using a JOptionPane for each value.

The program will then calculate the values for smooth.

The program will then output a list of both the signal values and the corresponding smooth values. This will take the form

``````Signal        Smooth
1         1
2         2
3         3
4         3
``````

Should the number of signals be less than 2 the program outputs an error message but with the addition that the values for signal and smooth are displayed in a single JOptionPane.

That is the assignment

``````import javax.swing.*;

class homework
{
public static void main(String args[])
{

int returnInt = getInt("Number of Signals", "Input");
int count = 0;

if (returnInt <2 )
{
JOptionPane.showMessageDialog(null, "Must enter more than 1 signal", "Output", JOptionPane.INFORMATION_MESSAGE);
}
else
{
while (count != returnInt)
{

int thenumbers1[] = new int [returnInt];
for (int n = 0; n < thenumbers1.length; n++)
{
String numbers = JOptionPane.showInputDialog(null, "Enter a number", "Input", JOptionPane.QUESTION_MESSAGE);
thenumbers1[n] = Integer.parseInt(numbers);
count = count + 1;

JOptionPane.showMessageDialog(null, thenumbers1[n], "Output", JOptionPane.INFORMATION_MESSAGE);
``````

this is what i have done so far and i have been trying to do the rest for 5-6 hours plz help im almost in tears

plz help anybody some ones done this on here before but i didnt understand anything he said on it :((((

You write a for loop and in each stage of the for loop you add that value and the immediate next one then average it.

Carry on until you reach the end of the for loop. What's not to get?