Need help with this code. Anyone with knowledge on java please help.
i found some on this forum, but that is also wrong. can anyone give me some help
what is want is to smooth the values in an integer array. If its totally wrong please dont yell
import java.io.*;
import javax.swing.*;
public class arraytest
{
public static void main(String args[])
{
String getsize = JOptionPane.showInputDialog(null,"enter a value for the size of the array:","Input",JOptionPane.QUESTION_MESSAGE);
int arraysize = Integer.parseInt(getsize);
int[] getsignal = new int [arraysize];
getsignal = getsignal(arraysize);
int[]getsmoothignal = smooth (arraysize.getsignal);
JOptionPane.showMessageDialog(null,showoutput(getsizearray,getsignal,getsmoothsignal)+"complete\n","Output",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
public static int[] getsignal(int s)
{
//declare
int[] getnumber = new int [s];
for(int index = 0; index < s; index++)
{
String getintstring = JOptionPane.showInputDialog(null,"enter value of array:","Input",JOptionPane.QUESTION_MESSAGE);
getnumber[index]=Integer.parseInt(getIntString);
while (getnumber[index]<2)
{
JOptionPane.showMessageDialog(null,"Please re-insert your values","Output",JOptionPane.ERROR_MESSAGE);
getIntString = JOptionPane.showInputDialog(null,"Enter values of array:","Input",JOptionPane.QUESTION_MESSAGE);
getnumber[index] = Integer.parseInt(getIntString);
}
}
return getnumber;
}
public static int[]smooth(int a, int[] signals)
{
int[]smooth = new int [a];
smooth[0]=(signals[0]+signals[1])/2;
for (int i = 1; i <= a - 2; i++)
{
smooth[i]=(signals[i-1]+signals[i]+signals[i+1])/3;
}
int endValue = a - 1;
smooth[endvalue]=(signals[endvalue-1]+signals[endvalue])/2;
return smooth;
}
public static string showOutput(int a, int[]signal,int[]smooth)
{
String output = "signal"+" "+smooth ;
for (int index = 0; index < a; index++)
{
output = signal[index]+" "+" " +smooth[index]+"\n";
}
return output;
}
}