jtentor

Untitled

Apr 13th, 2020 (edited)
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. package practico1;
  2. import java.util.Scanner;
  3.  
  4. public class Punto1 {
  5.  
  6. public static void main(String[]args) {
  7. Scanner sc = new Scanner(System.in);
  8.  
  9. String resp;
  10. do {
  11. System.out.print("Ingrese nombre: ");
  12. String nombre1= sc.next();
  13. System.out.print("Ingrese edad: ");
  14. int edad1=sc.nextInt();
  15. System.out.print("Ingrese nombre: ");
  16. String nombre2= sc.next();
  17. System.out.print("Ingrese edad: ");
  18. int edad2=sc.nextInt();
  19. int edadMayor;
  20. if(edad2>edad1) {
  21. edadMayor=edad2-edad1;
  22. System.out.println(nombre2+" es mayor por: "+edadMayor+" años.");
  23. }else if(edad2==edad1) {
  24. System.out.println("No hay difencia de edad");
  25. }
  26. else {
  27. edadMayor=edad1-edad2;
  28. System.out.println(nombre1+" es mayor por: "+edadMayor+" años.");
  29. }
  30. System.out.println("¿Queres ingresar otros nombres? si(s), no(n)");
  31. resp=sc.next();
  32.  
  33. }while (resp!="n");
  34. sc.close();
  35.  
  36. }
  37. }
Add Comment
Please, Sign In to add comment