jtentor icon

Untitled

jtentor | PRO | 08/18/20 02:23:50 PM UTC (Edited) | 0 ⭐ | 695 👁️ | Never ⏰ | []
Java |

850 B

|

None

|

0 👍

/

0 👎

package practico1;
import java.util.Scanner;
 
public class Punto1 {
 
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
 
String resp;
do {
System.out.print("Ingrese nombre: ");
String nombre1= sc.next();
System.out.print("Ingrese edad: ");
int edad1=sc.nextInt();
System.out.print("Ingrese nombre: ");
String nombre2= sc.next();
System.out.print("Ingrese edad: ");
int edad2=sc.nextInt();
int edadMayor;
if(edad2>edad1) {
edadMayor=edad2-edad1;
System.out.println(nombre2+" es mayor por: "+edadMayor+" años.");
}else if(edad2==edad1) {
System.out.println("No hay difencia de edad");
}
else {
edadMayor=edad1-edad2;
System.out.println(nombre1+" es mayor por: "+edadMayor+" años.");
}
System.out.println("¿Queres ingresar otros nombres? si(s), no(n)");
resp=sc.next();
 
}while (resp!="n");
sc.close();
 
}
}

Comments