Hello,
Someone ca,help me to resolve the last requirement
Thanks a lot
package fr.codegym.task.task08.task0828;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.Map;
/*
Nombre du mois
*/
public class Solution {
public static void main(String[] args) throws IOException {
//écris ton code ici
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String month = reader.readLine();
System.out.println(getNumeroMonth(createMonths(), month));
}
public static HashMap<Integer,String> createMonths() {
HashMap<Integer,String> dictionnary = new HashMap<>();
dictionnary.put(1, "January");
dictionnary.put(2, "February");
dictionnary.put(3, "March");
dictionnary.put(4, "April");
dictionnary.put(5, "May");
dictionnary.put(6, "June");
dictionnary.put(7, "July");
dictionnary.put(8, "August");
dictionnary.put(9, "September");
dictionnary.put(10, "October");
dictionnary.put(11, "November");
dictionnary.put(12, "December");
return dictionnary;
}
public static String getNumeroMonth(HashMap<Integer,String> dictionnary , String month) {
String resultat = "";
for(Map.Entry<Integer,String> elt : dictionnary.entrySet()) {
if (elt.getValue().equals(month)) {
resultat = month + " est le mois numéro "+ elt.getKey();
break;
}
}
return resultat;
}
}