Menu
Question Index
...


Write a program to parse the molecule and get the atoms count.

Input (String) Output (Map)
C6H12OH {C=6, O=1, H=13}
Fe2Cl3 {Cl=3, Fe=2}
H2SO3 {S=1, O=3, H=2}
NH4OH {N=1, O=1, H=5}
NaOH {O=1, H=1, Na=1}

class ParseMolecule

{    public static void main(String s[])
    {
        System.out.println("The atoms count in the molecule C6H12OH is :" + getElementsMap("C6H12OH"));

    }


public static Map<String, Integer> getElementsMap(String molecule) {
//Write code here to get the parse molecule and return it.
}
}

Doubts

Problems

Topic: Java HashMap Implementation

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App