Find the max number of molecules that it is possible to create H2SO4 so for 1 molecule is needed -2 atoms of H
-1 atom of S
-4 atoms of O
This code gives me just one possible molecule, but it is possible to create more
public static void numOdMol(int hydrogen, int oxygen, int sulfur) {
int counter=0;
if ( hydrogen >= 2 && oxygen >= 1 && sulfur >= 4) {
counter++;
}
System.out.println(counter);
}
public static void main(String[] agrs) {
Test.numOdMol(5, 7, 35);
Aucun commentaire:
Enregistrer un commentaire