Leer nombre y edad de 2 personas y desplegar quien es la de mayor edad
import java.util.*;
class xclase extends clases{
private String nombre;
private int edad;
public xclase (String nombre, int edad) {
this.nombre = nombre;
this.edad = edad;
}
public String xnombre(){
return nombre;
}
public int xedad(){
return edad;
}
}
class clases {
public static void main(String args[]) {
String nom1,nom2;
int edad1,edad2;
Scanner teclado = new Scanner (System.in);
System.out.println("Escribe el primer nombre");
nom1=teclado.next();
System.out.println("Escribe su edad");
edad1 = teclado.nextInt();
System.out.println("Escribe el segundo nombre");
nom2=teclado.next();
System.out.println("Escribe su edad");
edad2 = teclado.nextInt();
xclase objeto1 = new xclase(nom1,edad1);
xclase objeto2 = new xclase(nom1,edad2);
if (objeto1.xedad()<objeto2.xedad()){
System.out.println(objeto2.xnombre()+"es mayor");
}
else {
System.out.println(objeto1.xnombre()+"es mayor");
}
}
}