Skip to content

Instantly share code, notes, and snippets.

@JoseLuisGardunoArrieta
Forked from eduardojesus12/Codigo5.java
Created November 29, 2024 16:30
Show Gist options
  • Save JoseLuisGardunoArrieta/35fe629bc0252ef712daa770f433171a to your computer and use it in GitHub Desktop.
Save JoseLuisGardunoArrieta/35fe629bc0252ef712daa770f433171a to your computer and use it in GitHub Desktop.
Código de otros 5
public class Codigo5 {
Scanner s = new Scanner();
System.out.print("Introduzca un número: ');
String ni = s.nextLine();
int c = ni;
int afo = 0;
int noAfo = 0;
while (ni > 0) {
int digito = (int)(ni % 10);
if ((digito == 3) || (digito == 7) || (digito == 8) || (digito == 9)) {
afo++;
} else {
noAfo++;
ni /= 10;
}
if (afo > noAfo) {
System.out.prinln("El " + c + " es un número afortunado.");
} else {
System.out.println("El " + c + " no es un número afortunado.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment