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
From the philosophical standpoint, especially in the discussion of moral philosophy or ethics, why do we consider “murder” or “k
wlad13 [49]

Explanation:

Morality is a set of values ​​and habits that a society acquires over time and can be categorized as good and bad values, right and wrong, justice and crime. Ethics is defined as the study of morals, the practical application of moral behaviors defined by society.

Therefore, the concept of "murder" or "killing" is seen as an immoral act by the vast majority of society around the world, strengthened by the set of moral conduct common to all human beings, which are the Articles on the Universal Declaration of Human Rights. Human Rights, which is an official document of the UN, which contains several universair and analytical rules on the rights of every individual, such as the right to life, security, freedom, etc.

7 0
3 years ago
The new software organization requires a new point of sale and stock control system for their many stores throughout Pakistan to
FrozenT [24]

Answer:

hdyfhwjhsucndiskfbvienucuit

7 0
3 years ago
We discussed in class the differences between Ruby and a language like Java. Based on our discussions, when do you feel it would
EleoNora [17]

Answer:

Ruby

It’s not a secret that our company places a bet on this interpreted scripting language created by Yukihiro Matsumoto in the far 1995. A bunch of deep-rooted technologies like Smalltalk, Python, Perl, Ada, C++, and others had an impact on shaping Ruby’s syntax and features. As a result, we got a technology known for elegant and expressive coding, as well as increased flexibility and productivity of development. It means that engineers take pleasure in writing code with Ruby and are not restricted in their vision on how to execute one thing or another.

Java

Despite Railsware’s unhidden preference towards Matsumoto’s brainchild, Java is also a part of our team’s arsenal. For example, we leveraged it together with other technologies within the Philips Directlife project. That’s to say, we know both of them and are happy to use whichever language best suits the task at hand.

In a sign of numerous Java and Ruby differences to be described a bit later, there is one undisputed similarity – they were born in the same year. Nevertheless, since then, Java has come through 11 versions with Java SE 11 as the latest one (compared to the Ruby’s latest release of 2.6.0). The technologies that influenced the creation of Java include C++, Ada 83, Object Pascal and others.

The TIOBE index shows that this compiled programming language overcame C in ranking and holds the first position as of the end of 2018. Moreover, it is a primary technology for Android native app development, which by the way was recently enhanced with Kotlin. Another facet of Java is that it is also an ecosystem of tools including Java Development Kit (JDK) for writing/running/compiling Java code, Java Virtual Machine (JVM) for running software built with Java and JVM languages within the same infrastructure to some degree of interoperability (for example, Kotlin for expressiveness and conciseness, Scala for functional programming, etc.), and Java Runtime Environment (JRE) for running Java apps. The basic points why developers opt for this technology are its reliability, platform independence, and ease of use.

Explanation:

The readers of our blog have already had a chance to get to know the duel of Ruby vs. PHP, as well as the combat Python vs. Ruby vs. Node.js. Today, we have Java vs. Ruby in turn.

Traditionally, we’re going to look at both technologies from a product owner’s perspective, which means learning not only technical differences between the languages, but also their actual use across different projects. Here we go.

Warm-up

Before any competition, the contestants need to warm up. It also happens that this term is used by one of the wrestlers, Java, for the lazy class loading of Java Virtual Machine. So, let’s not step out of line and have the competitors spiffed up to the battle.

Ruby

It’s not a secret that our company places a bet on this interpreted scripting language created by Yukihiro Matsumoto in the far 1995. A bunch of deep-rooted technologies like Smalltalk, Python, Perl, Ada, C++, and others had an impact on shaping Ruby’s syntax and features. As a result, we got a technology known for elegant and expressive coding, as well as increased flexibility and productivity of development. It means that engineers take pleasure in writing code with Ruby and are not restricted in their vision on how to execute one thing or another.

At the same time, this technology cannot be called popular. According to the TIOBE index as of December 2018, it is ranked 17th. Nevertheless, the language is not dying and keep afloat with the 3.0 version expected to be released in 2020. To sum up, Ruby allows programmers to enjoy what they do and be productive at once by following the principle of least astonishment.

Ruby key features

Apart from comparing Ruby to Java, let’s take a look at some key things one should know about this gem of a language.

Open-source

Interpreted language

Multi-platform

Dynamic + duck typing

Has a smart garbage collector

Everything including methods, numbers and variable is an object

You can embed Ruby into HTML

High scalability

Applicable for writing CGIs, building web and intranet apps

Support of different GUI tools including OpenGL, Tcl/Tk, and GTK

Support of Sybase, Oracle, MySQL, and DB2 connection

4 0
4 years ago
When we consider data quality, what are the differences among validity, reliability, and representativeness? How can you know th
MArishka [77]

Answer:

Validity is the degree to which the research measures what it has to measure. High validity = Proper Research Design.

Reliability is the measure to which research measurement techniques are free of error or mistakes. High realiability = Reasearchers know the sample fully understands the question asked.

Representativeness is the extent to which consumers in a study are similar to the larger group of interest. High representativeness = Sample is large and chosen in an unbiased way.

3 0
4 years ago
Use a search engine and spot the sponsored results for safer internet day.
snow_tiger [21]
What’s the question?
4 0
3 years ago
Other questions:
  • Linda has written a program that works well on various operating systems, but she needs to increase the readability of the progr
    14·1 answer
  • Which layer of the osi model defines services to segment and reassemble data for individual communications between end devices?
    15·1 answer
  • 11. If the following pseudocode were an actual program, what would it display:
    6·2 answers
  • How are blogs and wiki alike
    15·2 answers
  • Which data type requires the greatest number of bytes in computer memory? A. character B. integer C. single-precision number D.
    14·1 answer
  • Users report that the network access is slow. After questioning the employees, the network administrator learned that one employ
    10·1 answer
  • The concept of the internet was developed by the u.s. department of defense as a network that ________ in event of an attack.
    8·1 answer
  • Project: Baseline, Benchmark, Objective, and Goal
    14·2 answers
  • How do u mark bralienst
    5·1 answer
  • He is the person behind the development of electronic mail
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!