I need to create a program using the getAverage method and the main method to have the user input five chars and then calculate/print the average ASCII value and the highest letter, but Eclipse is giving me a lot of errors and I am not really sure what I am doing
public static int getAverage(char [] ascii, int [] decimal, int [] letters) {
{
System.out.println("Enter 5 letters from the English Alphabet: ");
Scanner input = new Scanner(System.in);
IM TRYING TO GET THE LETTER TO STORE AS AN ASCII NUMBER HERE
System.out.println("Letter 1 (a-z or A-Z): ");
char a = (input.next()).charAt(0);
int letterOne = -1;
for(int i=0; i<ascii.length; i++){
if (ascii[i] == a)
letterOne=i;
}
System.out.println("Letter 2 (a-z or A-Z): ");
char b = (input.next()).charAt(0);
int letterTwo = -1;
for(int i=0; i<ascii.length; i++){
if (ascii[i] == b)
letterTwo=i;
}
System.out.println("Letter 3 (a-z or A-Z): ");
char c = (input.next()).charAt(0);
int letterThree = -1;
for(int i=0; i<ascii.length; i++){
if (ascii[i] == c)
letterThree=i;
}
System.out.println("Letter 4 (a-z or A-Z): ");
char d = (input.next()).charAt(0);
int letterFour = -1;
for(int i=0; i<ascii.length; i++){
if (ascii[i] == d)
letterFour=i;
}
System.out.println("Letter 5 (a-z or A-Z): ");
char e = (input.next()).charAt(0);
int letterFive = -1;
for(int i=0; i<ascii.length; i++){
if (ascii[i] == e)
letterFive=i;
}
I DONT KNOW HOW TO MAKE THESE INTO AN ARRAY THAT I CAN USE IN THE MAIN
int[] letter = new int{letterOne, letterTwo, letterThree, letterFour, letterFive};
int [] lettersArray = {a, b, c, d, e};
int average = ((a+b+c+d+e)/5);
System.out.println("Your average value is: " + average);
NOT SURE WHAT TO RETURN HERE IF ANYTHING?
return ;
}
public static void main(String[] args)
{
int [] decimalArray = new int[52];
char[] asciiArray = new char[52];
int base = 65;
for (int i=0; i<26;i++){
decimalArray[i] = base;
asciiArray[i] = (char) base;
base++;
}
base = 97;
for(int i = 26; i<52; i++){
decimalArray[i] = base;
asciiArray[i] = (char) base;
base++;
}
int [] lettersArray = new int[5];
NOT SURE HOW TO CHANGE FROM A CHAR TO AN INT HERE
int[] letters = new int[5];
char max = letters[0]
for(int i = 0; i<5; i++){
if(max < letters[i])
max = letters[i];
}
getAverage(asciiArray, decimalArray, lettersArray);
System.out.println("The highest letter is: " + max);
}
}