Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

On most telephone keypads the letters of the alphabet are mapped to various digi

ID: 3803171 • Letter: O

Question

On most telephone keypads the letters of the alphabet are mapped to various digits as shown in the picture attached.

In order to make their phone numbers more memorable, service providers like to find numbers that spell out some word (called a mnemonic) appropriate to their business that makes that phone number easier to remember. For example, the phone number for a physician called Smith could be 377 -6484 (DRSMITH). Write a method listMnemonics that will generate all possible letter combinations that correspond to a given number, represented as a string of digits using a recursive function. This is a recursive backtracking problem, but you are trying to find all the "solutions", not just one. In fact you are trying to find all possible Strings using the English alphabet, not just Strings that are actual "words".
For example, if you call the method listMnemonics with the value 623 your method shall generate and return the following 27 possible letter combinations that correspond to that prefix:
MAD MBD MCD NAD NBD NCD OAD OBD OCD
MAE MBE MCE NAE NBE NCE OAE OBE OCE
MAF MBF MCF NAF NBF NCF OAF OBF OCF
Note, the order of these returned strings is unimportant.

Use the GUI depicted above to input required data. (you do not have to input a 7 – 10 digit number. Three digits will suffice)
I will let you decide how you wish to display the out from the inputted string.

This is a GUI program so the GUI must be implemented. It must look like the keypad and the user presses the buttons for input. It must use recursion as well.


Please add comments to your program!

Thank you!

DEF ABC 3 GHI JKL MNO 4 5 6 PQRS TUV WXYZ 7 8 9

Explanation / Answer

import java.lang.system;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JButton;

import javax.swing.JTextField;

public class VirtualKboard extends JFrame implements KeyListener

{

private JButton

A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,

Tab,Caps,Shift,Backspace;

private JTextField textField;

private String keyText;

private JLabel label1;

private JLabel label2;

private Object[] keys;

int keycode;

public VirtualKeyboard()

{

super("Typing Application");

setLayout( new FlowLayout() );

label1 = new JLabel("Type some text <a href="#">using</a> your <a href="#">keyboard</a>. The keys you press will be "

+ "highlighed and the text will be displayed");

add(label1);

label2 = new JLabel("Note: clicking the buttons with mouse will not perform any action");

add(label2);


textField = new JTextField(80);

textField.setEditable(true);

add( textField , BorderLayout.NORTH);


TextFieldHandler handler = new TextFieldHandler();

Backspace = new JButton( "Backspace" );

add(Backspace);

Tab = new JButton( "Tab" );

add(Tab);

Q = new JButton( "Q" );

add(Q);

W = new JButton( "W" );

add(W);

E = new JButton( "E" );

add(E);

R = new JButton( "R" );

add(R);

T = new JButton( "T" );

add(T);

Y = new JButton( "Y" );

add(Y);

U = new JButton( "U" );

add(U);

I = new JButton( "I" );

add(I);

O = new JButton( "O" );

add(O);

P = new JButton( "P" );

add(P);

Caps = new JButton ( "Caps ");

add(Caps);
A = new JButton( "A" );
add(A);

S = new JButton( "S" );

add(S);

D = new JButton( "D" );

add(D);

F = new JButton( "F" );

add(F);

G = new JButton( "G" );

add(G);

H = new JButton( "H" );

add(H);

J = new JButton( "J" );

add(J);

K = new JButton( "K" );

add(K);

L = new JButton( "L" );

add(L);

Shift = new JButton ( "Shift" );

add(Shift);

Z = new JButton( "Z" );

add(Z);
X = new JButton( "X" );

add(X);

C = new JButton( "C" );

add(C);

V = new JButton( "V" );

add(V);

B = new JButton( "B" );

add(B)/>;

N = new JButton( "N" );

add(N);

M = new JButton( "M" );

add(M);

}

public void keyPressed( KeyEvent event )
{
keycode = event.getKeyCode();

}

public void keyReleased( KeyEvent event )

{

keycode = event.getKeyCode();

keyText = String.format( "%s",KeyEvent.getKeyText( event.getKeyCode() ) );

getBackground();

}

public void keyTyped( KeyEvent event )

{

keyText = String.format( "%s", event.getKeyChar() );
}


private class TextFieldHandler implements ActionListener

{

public void actionPerformed( ActionEvent event )

{


if ( event.getSource() == textField )

string = String.format( "%s", event.getActionCommand() );
}
}
}

import javax.swing.JFrame;

public class VirtualKeyboardTest

{

public static void main(String[] args)

{

VirtualKeyboard typingWord = new VirtualKeyboard(); // <a href="#">create</a>s TypingWord

typingWord.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

typingWord.setSize(800, 600);
typingWord.setVisible(true);

JFrame frame = new JFrame();

}   

}   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote