1
Given a sequence of integers (read via Scanner
), determine the lower of these values.
My code:
import java.util.Scanner;
public class MenorValorSequencia {
public static void main (String args []) {
Scanner sc = new Scanner (System.in);
int [] variavel = new int [10];
for (int i = 0; i<=9; i++) {
variavel[i] = sc.nextInt();
}
int menorValor = 0;
for (int i = 0; i<=9; i++) {
if (variavel[i]<menorValor) {
menorValor = variavel[i];
}
System.out.println (menorValor(i)); // erro: não pode achar variável menorvalor
}
}
}
Java code for this problem can be done like this?
Please do not use bold in the whole text, the feature is to highlight points that are important only
– user28595
And you are treating variable as if it were a method, menorValue is a variable, there is no such call
menorValor(i)
. Remove the(i)
in front.– user28595
Did any of the answers below solve your problem? Do you think you can accept one of them? Check out the [tour] how to do this, if you still don’t know how to do it. This helps the community by identifying the best solution for you. You can only accept one of them, but you can vote for any question or answer you find useful on the entire site (if you have enough score).
– Maniero