Click the Twitter icon to follow our tweets and
know more about us.

Electronic configuration with full details and exception(till 30)

class electronic1to30
{
   public static void main(int z)
   {
       String sb[]={"","1s","2s","2p","3s","3p","4s","3d"};
       String e[]={"","Hydrogen(H)","Helium(He)","Lithium(Li)","Beryllium(Be)","Boron(B)",
"Carbon(C)","Nitrogen(N)","Oxygen(O)","Flourine(F)","Neon(Ne)","Sodium(Na)","Magnesium(Mg)"
,"Aluminium(Al)","Silicon(Si)","Phosphorus(P)","Sulphur(S)","Chlorine(Cl)","Argon(Ar)",
"Potassium(K)","Calcium(Ca)","Scandium(sc)","Titanium(Ti)","Vanadium(V)","Chromium(Cr)",
"Manganese(Mn)","Iron(Fe)","Cobalt(Co)","Nickel(Ni)","Copper(Cu)","Zinc(Zn)"};     
       int a[]=new int[8];int n=1, s=1; int sbsh[]={0,2,2,6,2,6,2,10}; int f=z;
       System.out.println("Atomic number is "+f);
       System.out.println("The name of the element is "+e[f]);
       System.out.println("The Electronic Configuration of "+e[f]+" is");

       while(z>0)
       {
           a[s]=z<sbsh[s]?z:sbsh[s];
           z=z-a[s];
           s++;
       }
       for(int j=1;j<8;j++)
       {
           if(j==6)
           {if(a[j+1]==4 || a[j+1]==9)
            {
                a[j+1]=a[j+1]+1;a[j]=a[j]-1;
            }
            }
           if(a[j]!=0)           
           System.out.print(sb[j]+"["+a[j]+"]"+" ");
        }System.out.println();
   }
}