<prompt> Andika kazi ya Java ambayo inakadiria ni ngapi ya vifungo vya keyboard vinavyohitaji kuandika kamba. Fikiria kwamba kamba za kuingiza zina herufi ndogo na kubwa tu za Kiingereza, nafasi na alama ya alama. Mfano: abcdeF- 7 kwa sababu kuandika F, unahitaji kubonyeza Shift. ABCDEf- 7 Unabonyeza Shift na kisha ubonyeze ABCDE. Hiyo ni bonyeza sita. Baada ya hapo unatoa shift na bonyeza f. Kwa hivyo, bonyeza 7.  <response>: Heres a possible implementation in Java:javapublic static int calculateKeypressString str Define arrays for upper and lower case letters char upperLetters ABCDEFGHIJKLMNOPQRSTUVWXYZ.toCharArray; char lowerLetters abcdefghijklmnopqrstuvwxyz.toCharArray; int keypresses 0; boolean shiftDown false; for char ch : str.toCharArray if ch keypresses; space is a separate button else if ch . ch , ch ! ch ? keypresses; punctuation is a separate button else if containsCharupperLetters, ch if !shiftDown keypresses; need to press shift first for upper case letters shiftDown true; keypresses; else if shiftDown keypresses; upper case mode needs to be turned off for lower case letters shiftDown false; keypresses; return keypresses;private static boolean containsCharchar arr, char ch for char c : arr if c ch return true; return false;The calculateKeypress function takes a string as input and returns the number of key presses needed to type that string. The function iterates over every character in the string, and counts how many key presses are needed for each character based on the rules given in the problem description.A boolean variable shiftDown keeps track of whether the Shift key is currently being held down. If an upper case letter is encountered while shiftDown is false, then the Shift key needs to be pressed first before typing that letter, and vice versa when going from upper case to lower case.The containsChar helper function is used to check whether a given character is a member of an array of characters. 