C Programs Tutorials | IT Developer
IT Developer

Java Programs - Solved 2025 Practical Paper ISC Computer Science



Share with a Friend

Solved 2025 Practical Paper ISC Computer Science

Class 12 - ISC Computer Science Solved Practical Papers

Cell Phone Keypad Program - ISC 2025 Practical

Most (not all) cell phone keypads look like the following arrangement (the letters are above the respective number):

For sending text/SMS, the common problem is the number of keystrokes to type a particular text.

For example, in the word “STOP”, there are a total of 9 keystrokes needed to type the word. You need to press the key 7 four times, the key 8 once, the key 6 three times and the key 7 once to get it.

Develop a program code to find the number of keystrokes needed to type the text.

For this problem, accept just one word without any punctuation marks, numbers or whitespaces and the text message would consist of just 1 word.

Test your data with the sample data and some random data:

Example 1:
INPUT: DEAR
OUTPUT: Number of keystrokes = 7

Example 2:
INPUT: Thanks
OUTPUT: Number of keystrokes = 12

 

Example 3:
INPUT: Good-bye
OUTPUT: INVALID ENTRY

import java.util.Scanner; class Keypad{ public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.print("Enter the word: "); String word = in.next().toUpperCase(); int count = 0; for(int i = 0; i < word.length(); i++){ char ch = word.charAt(i); if(!Character.isLetter(ch)){ System.out.println("INVALID ENTRY"); return; } if("ADGJMPTW".indexOf(ch) >= 0) count++; else if("BEHKNQUX".indexOf(ch) >= 0) count += 2; else if("CFILORVY".indexOf(ch) >= 0) count += 3; else count += 4; } System.out.println("Number of keystrokes = " + count); } }

Output

 
OUTPUT 1:
Enter the word: DEAR
Number of keystrokes = 7

OUTPUT 2:
Enter the word: Thanks
Number of keystrokes = 12


OUTPUT 3:
Enter the word: Good-bye
INVALID ENTRY