I need to receive a number n and then repeat the receipt and processing of the string v, n times. I tried the following:
import java.util.Scanner;
public class Main {
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int x = 1; x < n; x++){
String v = sc.next();
int valorLed = 0;
char [] numLed = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
char [] listV = v.toCharArray();
int k = 0;
int soma = 0;
for(int i = 0; i < listV.length; i++ ){
k = (listV[i]-48);
k = numLed[k];
soma += k;
}
System.out.print(soma +" leds");
}
}
}
However, it did not work. How to proceed? For example, if n equals 2, then I will receive two different V's and print two different outputs.