1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Illusion [34]
3 years ago
5

Phone numbers and PIN codes can be easier to remember when you find words that spell out the numberon a standard phone pad. For

example, instead of remembering the combination 5282, you can just think of JAVA.Write a recursive method that given a number, yields all possible spellings (which may or may not be real words).
Computers and Technology
1 answer:
Alik [6]3 years ago
7 0

Answer:

Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

Explanation:

Here is the completed code for the problem in the question above.

// PinWordEnumerator.java

import java.util.Scanner;

public class PinWordEnumerator {

               public static void main(String[] args) {

                               Scanner scanner = new Scanner(System.in);

                               System.out.print("Enter pin number: ");

                               String num = scanner.nextLine();

                               System.out.println();

                               System.out.printf("The keypad encodings for %s are:%n", num);

                               enumerateWords(num);

               }

               /**

               * method to return a character array containing all possible keypad

               * encodings for a digit in a standard phone

               */

               static char[] getKeysForButton(int n) {

                               switch (n) {

                               case 0:

                                               return new char[] { ' ' }; //returning only space

                               case 1:

                                               return new char[] { '.' }; //returning only dot

                               case 2:

                                               //button 2 contains A, B and C keys

                                               return new char[] { 'A', 'B', 'C' };

                               case 3:

                                               return new char[] { 'D', 'E', 'F' };

                               case 4:

                                               return new char[] { 'G', 'H', 'I' };

                               case 5:

                                               return new char[] { 'J', 'K', 'L' };

                               case 6:

                                               return new char[] { 'M', 'N', 'O' };

                               case 7:

                                               return new char[] { 'P', 'Q', 'R', 'S' };

                               case 8:

                                               return new char[] { 'T', 'U', 'V' };

                               case 9:

                                               return new char[] { 'W', 'X', 'Y', 'Z' };

                               }

                               return null;

               }

               /**

               * method to enumerate words

               *

               * "at"param num

               *            - String containing pin numbers, assuming it has only numbers

               */

               static void enumerateWords(String num) {

                               /**

                               * calling the recursive method to perform the enumeration

                               */

                               if (num != null)

                                               enumerateWords(num, "");

               }

               /**

               * the main method which performs the recursion

               *

               * "at"param num

               *            - current number

               * "at"param text

               *            - text containing converted spellings

               */

               static void enumerateWords(String num, String text) {

                               if (num.length() == 0) {

                                               // base case, displaying the text

                                               System.out.println(text);

                               } else {

                                               // finding the digit at 0th position

                                               int digit = num.charAt(0) - '0';

                                               // finding possible phone keys for this digit

                                               char letters[] = getKeysForButton(digit);

                                               if (letters != null) {

                                                               // looping through all possible keys

                                                               for (int i = 0; i < letters.length; i++) {

                                                                               /**

                                                                               * appending the current letter to the text and calling the

                                                                               * recursive method also neglecting the first letter of

                                                                               * current 'num' string

                                                                               */

                                                                               enumerateWords(num.substring(1), text + letters[i]);

                                                               }

                                               }

                               }

               }

}

/*OUTPUT*/

Enter pin number: 5282

The keypad encodings for 5282 are:

JATA

JATB

JATC

JAUA

JAUB

JAUC

JAVA

JAVB

JAVC

JBTA

JBTB

JBTC

JBUA

JBUB

JBUC

JBVA

JBVB

JBVC

JCTA

JCTB

JCTC

JCUA

JCUB

JCUC

JCVA

JCVB

JCVC

KATA

KATB

KATC

KAUA

KAUB

KAUC

KAVA

KAVB

KAVC

KBTA

KBTB

KBTC

KBUA

KBUB

KBUC

KBVA

KBVB

KBVC

KCTA

KCTB

KCTC

KCUA

KCUB

KCUC

KCVA

KCVB

KCVC

LATA

LATB

LATC

LAUA

LAUB

LAUC

LAVA

LAVB

LAVC

LBTA

LBTB

LBTC

LBUA

LBUB

LBUC

LBVA

LBVB

LBVC

LCTA

LCTB

LCTC

LCUA

LCUB

LCUC

LCVA

LCVB

LCVC

You might be interested in
When installing a Windows 10 an already installed Windows 7 what happen​
astra-53 [7]

Answer:

are u updating it? or u r rooting it?

4 0
3 years ago
Read 2 more answers
Define an organizational unit in your own words.
Musya8 [376]

Explanation:

An organizational unit (OU) is a subdivision within an Active Directory (hierarchical collection of network resources that can contain users, computers, printers, and other Active Directories) into which you can place users, groups, computers, and other organizational units. Each domain can implement its own organizational unit hierarchy, typically used either to differentiate between objects with the same name, or to parcel out authority to create and manage objects.

I hope you find this information useful and interesting! Good luck!

3 0
4 years ago
A personal identification number (PIN) that opens a certain lock consists of a sequence of 3 different digits from 0 through 9,
Elan Coil [88]

Answer:

<u>720</u> possible PIN can be generated.

Explanation:

To calculate different number of orders of digits to create password and PIN, we calculate permutation.

Permutation is a term that means the number of methods or ways in which different numbers, alphabets, characters and objects can arranged or organized. To calculate the permutation following formula will be used:

nPr = n!/(n-r)!

there P is permutation, n is number of digits that need to be organize, r is the size of subset (Number of digits a password contains)

So in question we need to calculate

P=?

where

n= 10   (0-9 means total 10 digits)

r= 3     (PIN Consist of three digits)

So by using formula

10P3 = 10!/(10-3)!

        =10!/7!

        = 10x9x8x7!/7!

        = 10x9x8

        = 720

7 0
3 years ago
Timur was making a presentation regarding how attackers break passwords. His presentation demonstrated the attack technique that
kakasveta [241]

Answer:

The answer of the following question is Brute force attack .

Explanation:

A brute force attack is the error and trial method that is used by an application program to decode the encrypted data like passwords or the Data Encryption Standard (DES) keys, which through an exhaustive effort (by using brute force) rather than the employing an intellectual strategies.

7 0
3 years ago
Pls I need a reply ASAP
GrogVix [38]

Answer: delete the application and install it again thats what worked for me.

Explanation:

6 0
3 years ago
Other questions:
  • Which of the following is not an impact device?<br> Joy Stick<br> Track Ball<br> Mouse<br> Printer
    10·1 answer
  • Maria found a cupcake recipe on a cooking blog. However, she would like to read comments and suggestions before she begins bakin
    6·2 answers
  • Jeremy Aronoff has purchased a new laptop. He wants to customize the operating system to meet his
    7·1 answer
  • When you open as many links as you want, and still stay in the same browser window instead of cluttering your screen with multip
    5·1 answer
  • You can place an insertion point by clicking in the field or by pressing ____.
    13·1 answer
  • + Use for loop to print numbers from 100 to 10
    11·1 answer
  • Nicole is in a study group to prepare for a test on plant biology, a subject she knows a lot about. During their meetings, she a
    8·2 answers
  • Describe how to add slide numbers and image to a Microsoft power point presentations ?​
    5·1 answer
  • Meera has created a small program in Python. She wants to store elements of the same data type in an organized
    7·1 answer
  • Can able to Computer decide its input by itself? How ?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!