0
My goal is to take the letter of the alphabet that the user typed and show, as many times as he type, the letters predecessor and successors of this, understand?
Look what I did:
static int v;
static String[] Alfa = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
"M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
public static void main(String[] args) {
String letra;
Scanner s = new Scanner(System.in);
System.out.print("Digite uma letra: ");
letra = s.nextLine();
System.out.print("Quantas letras deseja mostrar?");
v = s.nextInt();
for(int i = 1; i < Alfa.length; i++) {
if(letra == Alfa[i]) {
for(int i; i <= 1;) {
System.out.print(Alfa[i--] + " ");
}
System.out.print(Alfa[i]);
for(int i; i <= v;) {
System.out.print(" " + Alfa[i++]);
}
}
}
}
It turns out I have to use the value of the Alpha[i] that’s inside if we’re for’s, but how do I do that?
makes a
for
out to find out which vector position is the letter q he typed, dps afor
v vezes
showingi++
andi--
– guijob