3
I would like to pass the values stored in the variables of the Parte1 to the Parte2 to validate the highest entered value.
PART 1:
public class SEP_06_parte1{
public static void main(String args[]){
System.out.print("Digite 10 valores ");
int y1 = input.nextInt();
int y2 = input.nextInt();
int y3 = input.nextInt();
int y4 = input.nextInt();
int y5 = input.nextInt();
int y6 = input.nextInt();
int y7 = input.nextInt();
int y8 = input.nextInt();
int y9 = input.nextInt();
int y10 = input.nextInt();
SEP_06_parte2 lernumeros = new SEP_06_parte2();
lernumeros.determineMaior();
}
}
PART 2:
public class SEP_06_parte2{
public void determineMaior(){
int maiorResultado = maximum(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10);
System.out.print("Maior Numero: " + maiorResultado);
}
public static int maximum( int y1 , int y2, int y3, int y4, int y5, int y6, int y7, int y8, int y9, int y10)
{
int maximumValue = y1;
if ( y2 > maximumValue )
maximumValue = y2;
if ( y3 > maximumValue )
maximumValue = y3;
if ( y4 > maximumValue )
maximumValue = y4;
if ( y5 > maximumValue )
maximumValue = y5;
if ( y6 > maximumValue )
maximumValue = y6;
if ( y7 > maximumValue )
maximumValue = y7;
if ( y8 > maximumValue )
maximumValue = y8;
if ( y9 > maximumValue )
maximumValue = y9;
if ( y10 > maximumValue )
maximumValue = y10;
return maximumValue;
}
}
Friend, thanks for the help, what I want is to make a program that sees the largest number among 10 values typed by the user, I am starting now to work with LOO, I have always worked with Front-end development so I do not yet master Java, but I’m training for this... Again Thanks!
– CRAJ