String st=JOptionPane.showInputDialog(null,"Enter 1 or 2\n1- if you have the value of resistance :\n2-if you have the colors of resistance : ");
int choose=Integer.parseInt(st);
int resisranceValue[]=new int []{0,1,2,3,4,5,6,7,8,9};
String resistanceColor[]= new String[]{"black","brown","red","orange","yellow","green","blue","violet","gray","white"};
String s,out=" ",color;
int number;
if(choose==1){
for(int i=0;i<=2;i++){
s=JOptionPane.showInputDialog(null,"enter the first number then second number then number of zero :");
number=Integer.parseInt(s);
for (int c=0;c<resisranceValue.length;c++){
if(resisranceValue[c]==number)
out+=resistanceColor[c]+" ";
}
}
JOptionPane.showMessageDialog(null,"the color resistance is : "+out);
}
else{
for(int i=0;i<=2;i++){
color=JOptionPane.showInputDialog(null,"enter the first color then second color then third color :\n ( Forget gold or silver ) ");
for(int c=0;c<resistanceColor.length;c++){
if(resistanceColor[c].equals(color))
out+=resisranceValue[c]+" ";
}
}
JOptionPane.showMessageDialog(null,"the value of resistance is : "+out);
}