I have try to resolve this problem but if I have any mistake pls tell me...
can anyone explain something about ( k ) what does it need to be

Problem description:
POLYALPHABETIC SUBSTITUTION CIPHERS
As one can readily see, monoalphabetic substitution ciphers are notoriously easy to break.
In the case of the Caesar cipher, the shift value can be uncovered rather easily. One way clas-
sical cryptographers dealt with this was to use different shift values for letters depending on
their position in the text. For example, one may do something like the following:
Let a1, a2, . . . , an be the letters in a plaintext message. Consider the letter ap:
If p is divisible by 4, shift ap 7 letters down the alphabet.
If p is of the form 4k + 1 for some k, shift ap 5 letters down the alphabet.
If p is of the form 4k + 2 for some k, shift ap 13 letters down the alphabet.
If p is of the form 4k + 3 for some k, shift ap 2 letters down the alphabet.

source code by me:

Java Code:
public class Det4enc
{

	public static void main(String[] args) 
	{
		String str = "DEFCON FOUR";
		System.out.println (str);
		int key = 0;
		int k = 1;
		
		String encrypted = encrypt(str, key, k);
		System.out.println(encrypted);
	}
		
	public static String encrypt(String str, int key, int k) 
	{
		String encrypted = "";
		for(int i = 0; i < str.length(); i++) 
		{
			int c = str.charAt(i);
			
			//Caktimi i ndryshimit te qelsit
			if(i%4==0)
			key = 7;
			else if(i%(4*k+1)==0)
			key = 5;
			else if(i%(4*k+2)==0)
			key = 13;
			else if(i%(4*k+3)==0)
			key = 2;
			else
			key = 0;
			
			if (Character.isUpperCase(c)) 
			{
				c = c + (key % 26);
				if (c > 'Z')
				c = c - 26;
			} else if (Character.isLowerCase(c)) 
				{
					c = c + (key % 26);
					if (c > 'z')
					c = c - 26;
				}
			encrypted += (char) c;
		}
			return encrypted;
	}
}