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
|
public static void main(String[] args) {
boolean retVal;
int p=0, f=0;
String a = null, recherche = null ;
String hydrogene = "H",helium = "He";
String lithium ="Li", beryllium = "Be", bore = "B", carbone ="C", azote = "N", oxygene = "O", fluor = "F", neon = "Ne";
String sodium = "Na", magnesium = "Mg", aluminium = "Al", silicium = "Si", phosphore = "P", soufre = "S", chlore = "Cl", argon = "Ar";
String [][] tablop = {
{hydrogene,helium},
{lithium,beryllium,bore,carbone,azote,oxygene,fluor,neon},
{sodium,magnesium,aluminium,silicium,phosphore,soufre,chlore,argon}
};
Scanner lectureClavier = new Scanner(System.in);
System.out.println("Entrez un élément chimique : ");
a = lectureClavier.nextLine();
System.out.println(a);
for (p=0;p< tablop.length;p++) {
for (f=0; f< tablop[p].length; f++) {
recherche = tablop[p][f];
retVal = recherche.equals(a);
if (retVal) break;
else continue;
}
}
System.out.println("ligne " +p);
System.out.println("colonne " +f);
} |
Partager