import
java.util.*;
class
GFG {
static
void
findResistance(String a, String b, String c,
String d, String e)
{
HashMap<String, String> color_digit
=
new
HashMap<String, String>();
color_digit.put(
"black"
,
"0"
);
color_digit.put(
"brown"
,
"1"
);
color_digit.put(
"red"
,
"2"
);
color_digit.put(
"orange"
,
"3"
);
color_digit.put(
"yellow"
,
"4"
);
color_digit.put(
"green"
,
"5"
);
color_digit.put(
"blue"
,
"6"
);
color_digit.put(
"violet"
,
"7"
);
color_digit.put(
"grey"
,
"8"
);
color_digit.put(
"white"
,
"9"
);
HashMap<String, String> multiplier
=
new
HashMap<String, String>();
multiplier.put(
"black"
,
"1"
);
multiplier.put(
"brown"
,
"10"
);
multiplier.put(
"red"
,
"100"
);
multiplier.put(
"orange"
,
"1k"
);
multiplier.put(
"yellow"
,
"10k"
);
multiplier.put(
"green"
,
"100k"
);
multiplier.put(
"blue"
,
"1M"
);
multiplier.put(
"violet"
,
"10M"
);
multiplier.put(
"grey"
,
"100M"
);
multiplier.put(
"white"
,
"1G"
);
HashMap<String, String> tolerance
=
new
HashMap<String, String>();
tolerance.put(
"brown"
,
"+/- 1 %"
);
tolerance.put(
"red"
,
"+/- 2 %"
);
tolerance.put(
"green"
,
"+/- 0.5 %"
);
tolerance.put(
"blue"
,
"+/- 0.25 %"
);
tolerance.put(
"violet"
,
"+/- 0.1 %"
);
tolerance.put(
"gold"
,
"+/- 5 %"
);
tolerance.put(
"silver"
,
"+/- 10 %"
);
tolerance.put(
"none"
,
"+/-20 %"
);
if
(color_digit.containsKey(a)
&& color_digit.containsKey(b)
&& color_digit.containsKey(c)
&& multiplier.containsKey(d)
&& tolerance.containsKey(e)) {
String xx = color_digit.get(a);
String yy = color_digit.get(b);
String zz = color_digit.get(c);
String aa = multiplier.get(d);
String bb = tolerance.get(e);
System.out.println(
"Resistance = "
+ xx + yy
+ zz +
" x "
+ aa +
" ohms "
+ bb);
}
else
System.out.println(
"Invalid Colors"
);
}
public
static
void
main(String[] args)
{
String a =
"red"
;
String b =
"orange"
;
String c =
"yellow"
;
String d =
"green"
;
String e =
"gold"
;
findResistance(a, b, c, d, e);
}
}