info@meritcampus.com    +91-85006-22255
...

Write a program to calculate the weight fractions in an alloy given the weights for individual metals. Note that the fractions should add up to one.

Input (Map) Output (Map)
{Iron=92.0, Zinc=100.0, Calcium=36.9, Chromium=189.20, Nickel=29.0, Cobalt=102.0} {Iron=0.16755, Zinc=0.18212, Calcium=0.0672, Chromium=0.34456, Nickel=0.05281, Cobalt=0.18576}
{Copper=9.0, Potassium=16.9, Magnesium=36.2, Mercury=129.20, Nobelium=92.0, Terbium=102.0, Cerium=2.0} {Copper=0.02324, Potassium=0.04364, Magnesium=0.09347, Mercury=0.33359, Nobelium=0.23754, Terbium=0.26336, Cerium=0.00516}

``` import java.util.*; class CalculateWeightFractions {     public static void main(String s[])    {        Map<String, Double> weights = new HashMap<String, Double>();        weights.put("Iron", 92.0);        weights.put("Zinc", 100.0);        weights.put("Calcium", 36.9);        weights.put("Chromium", 189.20);        weights.put("Nickel", 29.0);        weights.put("Cobalt", 102.0);        System.out.println("The fractions of given elements are : " + getWeightFractions(weights));    }     public static Map<String, Double> getWeightFractions(Map<String, Double> weights) { ```
```     }      ```
``` } ```
0
Wrong
Score more than 2 points