-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodigo5.java
More file actions
34 lines (28 loc) · 773 Bytes
/
Codigo5.java
File metadata and controls
34 lines (28 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.Codigo5;
import java.util.Scanner;
public class Codigo5 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
System.out.println("Introduzca un número: ");
int ni = s.nextInt();
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.println("El " + c + " es un número afortunado.");
} else {
System.out.println("El " + c + " no es un número afortunado.");
}
}
s.close();
}
}