-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdias_mes.java
More file actions
28 lines (26 loc) · 858 Bytes
/
Copy pathdias_mes.java
File metadata and controls
28 lines (26 loc) · 858 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
import java.util.Scanner;
public class dias_mes {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Introduce el número del mes (1-12): ");
int mes = sc.nextInt();
int dias = 0;
switch (mes) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
dias = 31;
break;
case 4: case 6: case 9: case 11:
dias = 30;
break;
case 2:
dias = 28; // Ignorando años bisiestos para simplicidad
break;
default:
System.out.println("Mes inválido.");
sc.close();
return;
}
System.out.println("El mes " + mes + " tiene " + dias + " días.");
sc.close();
}
}