el mayor.
import java.util.Scanner;
public class Mayor {
static int mayor=0;
public static void main(String[] args) {
int n1=0;
int n2=0;
int n3=0;
Scanner read= new Scanner(System.in);
System.out.println("Escribe 3 numeros: ");
n1=read.nextInt();
n2=read.nextInt();
n3=read.nextInt();
int m = definir(n1, n2, n3);
System.out.println("El numero mayor es: "+m);
}
public static int definir(int n1,int n2, int n3){
if(n1>mayor){
mayor=n1;
}
if(n2>mayor){
mayor=n2;
}
if(n3>mayor){
mayor=n3;
}
return mayor;
}
}
No hay comentarios:
Publicar un comentario