I am trying to make a program, that lets me type in 10 characters and stores them in an array. just single characters are enough, for example (d, s, a, e, h, j, e,). and then lets me look for one of the chars using linear search algorithm and gives out the position within the array.
I tried to program it but I can only do it with integers. here is my code so far.
I don't know how to change it to letters / characters?
public static void main(String args[])
int c, n, search, array[];
Scanner in = new Scanner(System.in);
System.out.println("Enter number of elements");
n = in.nextInt();
array = new int[n];
System.out.println("Enter " + n + " Letters");
for (c = 0; c < n; c++)
array[c] = in.nextInt();
System.out.println("What letter do you want to find?");
search = in.nextInt();
for (c = 0; c < n; c++)
{
if (array[c] == search) /* Searching element is present */
{
System.out.println(search + " is present at location " + (c + 1) + ".");
break;
}
if (c == n) /* Searching element is absent */
System.out.println(search + " Letter is not found.");