I imagine it to be a school exercise or something, after all, presenting options to choose the user in a textual way is generally not ideal for practical use.
As the problem of the question has already been solved by @bigown, a response based on Levenshtein's distance, which will find things with small differences in spelling, follows as a joke (by the exaggeration factor):
import java.util.*;
import java.lang.*;
import java.io.*;
class Alimentos {
//http://rosettacode.org/wiki/Levenshtein_distance#Java
public static int distance(String a, String b) {
a = a.toLowerCase();
b = b.toLowerCase();
int [] costs = new int [b.length() + 1];
for (int j = 0; j < costs.length; j++)
costs[j] = j;
for (int i = 1; i <= a.length(); i++) {
costs[0] = i;
int nw = i - 1;
for (int j = 1; j <= b.length(); j++) {
int cj = Math.min(
1 + Math.min(costs[j], costs[j - 1]),
a.charAt(i - 1) == b.charAt(j - 1) ? nw : nw + 1
);
nw = costs[j];
costs[j] = cj;
}
}
return costs[b.length()];
}
public static void main(String args[]){
String[] alimentos = new String[4];
alimentos[0] = "Vegetariano";
alimentos[1] = "Peixe";
alimentos[2] = "Frango";
alimentos[3] = "Carne";
String alimento;
String resultado;
int distancia;
int prevDistancia;
Scanner in = new Scanner(System.in);
System.out.println("Digite o Alimento (Vegetariano, Peixe, Frango ou Carne): ");
while ( in.hasNext() ) {
alimento = in.nextLine();
prevDistancia = 99999; // Valor maior do que qq distancia possivel aqui
resultado = "";
for ( String item : alimentos ) {
distancia = distance( item, alimento );
if ( prevDistancia > distancia ) {
prevDistancia = distancia;
resultado = item;
}
}
System.out.println("Alimento: "+resultado );
}
}
}
Taking advantage of it, I modified the code to accept several entries then until the user left the line blank, and in the output the four options, not just Vegetarian, appear.
Example entries, purposely spelled differently than code:
Framgo
Pexe
Vegetais
Carnes
Results:
Digite o Alimento (Vegetariano, Peixe, Frango ou Carne):
Alimento: Frango
Alimento: Peixe
Alimento: Vegetariano
Alimento: Carne
See working at IDEONE .