Menu
Topics Index
...
`

Parse the molecule and get the atoms count


If you need explanation Read this topic

If you need Answer Take test on this topic

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}


import java.util.*;
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) {
    }

}
Topic: Java HashMap Implementation

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

This dose is now closed and the winners are . The 'lucky liker' is Gaurav Bansal. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2015-01-29 06:39:37


© meritcampus 2019

All Rights Reserved.

Open In App