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 35 36 37 38 39 40 41 42 43 44 45 46 47
| import java.util.Scanner;
public class Paques {
private final static Scanner clavier = new Scanner(System.in);
static int demanderAnnee(int y){
do {
System.out.println("Entrez une annee (1583-4000) :");
y = clavier.nextInt();
} while ((y < 1583) || (y > 4000));
return y;
}
static int datePaques(int j, int y, int s, int p, int q, int m, int n, int d, int e){
y = demanderAnnee(y);
s = y / 100;
p = ((13 + 8) * s) / 25;
q = s / 4 ;
m = (15 - p + s -q)%30;
n = (4 + s -q)%7;
d = ( (m + (19 * y%19) ) )%30;
e = (2 * (y%4) + 4 * (y % 7) + 6 * d + n) % 7;
j = e+d+22;
if (((e == 6) && (d == 29)) || ((e == 6) && (d == 28) && (11*(m+1)%30 < 19))){
j = j - 7;
}
if (j > 31){
return (j - 31);
} else
return j;
}
static String afficheDate(int mois){
String[] mars = {"mars"};
String[] avril = {"avril"};
if (j > 21 && j<56 && j<=31){
return String[] mars;
}
if (j > 21 && j<56 && j>=32){
return String[] avril;
}
}
//Afficher résultats
public static void main(String[] args){
demanderAnnee(y);
afficheDate(mois);
datePaques();
System.out.println("Date de Paques en " + demanderAnnee() + " : " + datePaques() + " " + afficheDate());
}
} |
Partager