Dear friend
next time when posting please use tag code which is under symbol #, its make it easier to read the code. Thank you.
To your code. I took time to check it after initiatial 3 errors which I sorted come another 38. All this errors are related to your un-standart code writing. When documentation say
import javax.swimg.JOptionPane;
it is not same as yours
import javax.swing.joptionpane;
Java is not benevolent HTML where capital and lower letters can be mixed up as you wish. So please check all your coding for these mistakes and corect it and post it again if you get into troubles
Bellow you find the first correction which I made after first compile
import javax.swing.joptionpane;
public class homework7
{
public static void main(string args[])
{
//prompt user to insert a value of signal array
String getsizearraystring = Joptionpane.showinputdialog(null,
"enter a value for the size of the array:","Homework7",
Joptionpane.question_message);
int getsizearray = integer.parseInt(getsizearrayString);
//declare
int[] getsignal = new int [getsizearray];
getsignal = getsignal(getsizearray);
int[]getsmoothsignal = smooth (getsizearray.getsignal);
//display output
Joptionpane.showinputmessagedialog(null,
showoutput(getsizearray,getsignal,getsmoothsignal)+"complete\n",
"homework7",Joptionpane.information_message);
System.exit(0);
}
//return get array value method
public static int[] getsignal(int s)
{
//declare
int[] getnumber = new int [s];
//prompt user to insert values of the array
for(int index = 0; index < s; index++)
{
String getintstring = joptionpane.showinputdialog(null,
"enter value of array:","homework7",
Joptionpane.question_message);
getnumber[index]=integer.parseInt(getIntstring);
//error message is shown if the user value that are less than 2
while (getnumber[index]<2)
{
Joptionpane.showmessagedialog(null,
"there is an error \n" + "Please re-insert your values","homework7",
Joptionpane.error_message);
getIntString = Joptionpane.showinputdialog(null,
"Enter values of array:","Homework7",Joptionpane.question_message);
getnumber[index] = integer.parseInt(getIntString);
}
}
return getnumber; <strong>// you had as get number in 2 words</strong>
}
//return calculation
public static int[]smooth(int a, int[] signalss)
{
//declare
int[]smooth = new int [a];
//calculate the values of 1st element
smooth[0]=(signals[0]+signals[1])/2;
//calculate the values of middle element
for (int i = 1; i <= a - 2; i++)
{
smooths[i]=(signals[i-1]+signals[i]+signals[i+1])/3;
}
//calculate the last element
int endValue = a - 1;
smooths[endvalue]=(signals[endvalue-1]+signals[endvalue])/2;
return smooths;
}
//return the output message
public static string showOutput(int a, int[]signal,int[]smooth)
{
String output = "signal"+" "+smooth +"\n"; <strong>// missing plus and quotation sign " after smooth</strong>
for (int index = 0; index < a; index++)
{
output += signal[index]+" "+" " +smooth[index]+"\n";
}
return output;
}
} peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902