• Register
Welcome to Kodlogs Q&A, programming questions and answer website.

Most popular tags

java python javascript android c# r mysql program spring python-3 php c windows x sql-server spring-boot numpy eclipse sockets arrays exception tomcat ggplot2 ios hibernate sql jdbc jquery string html python-2 ssl node js 7 list entity-framework keytool matlab pandas django git linux csv facebook json asp net java-8 intellij-idea ssl-certificate spring-mvc amazon-web-services reactjs unit-testing macos minecraft pip maven xcode security database class google-chrome elasticsearch tsql unity3d heap-memory for-loop scikit-learn machine-learning winforms glmnet webpack illegalstateexception redirect junit tensorflow docker ubuntu typeerror loops css cmd tcp math datetime cryptography loop int import https x11 sql-server-2012 laravel-5 pdo fatal-error struts java-applet pytorch runtime-error conda visual-studio apache-spark pyspark garbage-collection sql-server-2005 facebook-graph-api entity-framework-4 reporting-services anova keras indentation-error laravel android-studio jupyter-notebook tcplistener orm qt virtualenv webclient prediction headless visual-studio-2010 compiler-errors numpy-ndarray sudo postgresql curl vagrant aspnet reporting dataframe npm nullpointerexception javafx jsp gradle gcc jpa wordpress servlet indentation mongodb firebase scanner sum github deployment socketexception certificate util oracle recursion search syntax connection float httpwebrequest ajax excel dictionary main function number file html5 2 google-chrome-extension payment-gateway error-handling magento paypal aws-vpc amazon-iam aws-lambda executionexception html5-canvas vmware-workstation junit5 kotlin floating-point-precision autowired lifecycleexception catalina return-value joptionpane dom postgresql-9 wkwebview webkit cgroups mingw xming inno-setup jasmine osx-mavericks firebase-cloud-messaging google-play-services xcodebuild facebook-login ruby-on-rails-3 pdfkit selenium-chromedriver selenium-webdriver makefile android-gradle-plugin android-ndk cross-domain xcode6 sybase jsp-tags data-files zoo web-development-server xss functional-dependencies mysql-error-1064 node-sass gulp-sass archlinux sass data-science spring-batch psycopg2 backpropagation texture2d async-await net-mvc-4 google-calendar ruby-on-rails-4 ruby-on-rails dbmigrate wp-mail github-for-windows facebook-android-sdk jsx xcb microsoft-metro react-router spring-data-jpa softmax elastic-beanstalk google-sheets-api google-spreadsheet-api cnf minidump xuggler acumatica gitlab elasticsearch-5 app-transport-security ios10 ios9 cdn cloudflare wampserver plpgsql aptitude systemd salt-stack sysv parent-child android-edittext textview visual-studio-2012 android-workmanager unique-index unity2d electron theano maven-compiler-plugin pickle assetbundle rstudio bar-chart python-tesseract tomcat6 primefaces solr easymock jvm-crash tomcat7 apache-httpclient-4 web-services woodstox discord jersey-2 prepared-statement resultset sencha-cmd sencha-touch-2 sencha-touch wkhtmltopdf powermock fips apex x509certificate ibm-bpm websphere-7 file-permissions file-io accesscontrolexception grizzly atmosphere slick2d lwjgl informetica twitter-bootstrap-3 jax-rs resteasy spring-security-kerberos spring-security kerberos long-integer mapnik git-review vpython continuation homebrew xgboost android-asynctask stack-trace user-interface jaxws-maven-plugin maven-3 maven-2 browser-notsupportedexception google-maps-api-3 google-maps visual-studio-code truststore firebase-authentication aws-organizations php-7 string-formatting cplusplus visual-studio-2015 net-core net-mvc msbuild extension-methods foreign-keys windows-services react-redux inputstream quirks-mode internet-explorer-9 internet-explorer reportingservices-2005 debian linear-regression deep-learning block-device melt reshape2 floating-point webpack-dev-server javascrip 0-lollipop android-5 statsmodels avx eclipseide javafx-2 php-not-recognized command-line putty phpmyadmin tinyurl classnotfoundexception atom-editor android-emulator android-sdk-tools ionic2 cordova foobar2k net-2 net-4 ole-db-provider export-to-excel openrowset windows-10 vagrantfile jvm-arguments global-variables sqlexception autopostback classformatexception eof upstart ipv4 graphviz pydot atom curses unityeditor pandoc tesseract xls oledb redux spotify cxf wamp nio stacked typescript hyperlink outlook jackson ssh keystore applicationcontext iis jstl encryption perfect-square objective-c carthage xcode8 indexing standard-deviation apt xampp printer connector apple cpanel mdf kubernetes destructor gettime arithmeticexception mix iphone probability ioexception heuristics milliseconds disk angular cpu code program modx-revolution goldsky modx prevnext javascript-dictionary stack-smashing device-monitor radio-button android-actionbaractivity android-activity android-fragments java-long unqualified-id ora-12154 javc c++ java nullpointerexception runtime-error drjava awt-eventqueue dsx math-pow ajquery nosuchelementexception appcompatactivity jsf jtextfield awt jpanel thymeleaf inputmismatchexception glassfish deque anaconda jupyter flask lvalue swing servlets netbeans jdk simulation ibm na factorial javax apache arduino boot opengl virtualbox jar jvm margins 2147483647 cloud plot ruby angularjs plugins automation crash card install repository odbc push installer pointers annotations merge editor concatenation swift formatting printf debugging devices module testing color arraylist sequence nested date variables caching expected build response ip pdf directory decimal algorithms release express collections print figure casting url expression validation integer microsoft sorting sort read logging types replace rest limit 8 4 email exe message required text 1 variable time size dll system files table runtime static random code web map http error version 0 my
0 votes
16 views
How do i convert a sentence into its equivalent mobile numeric keypad sequence? Any c# code example ?
by (930 points)  

2 Answers

0 votes
Given a sentence as a string, convert it into its proportional versatile numeric keypad grouping.

Pursue the means offered underneath to change over a sentence into its identical portable numeric keypad succession.

For each character, store the succession which ought to be gotten at its separate position in an exhibit, for example for Z, store 9999. For Y, store 999. For K, store 55, etc.

For each character, subtract ASCII estimation of 'An' and acquire the situation in the cluster pointed

by that character and include the succession put away in that cluster to a string.

In the event that the character is a space, store 0

Print the general grouping.

/C++ execution to change over a

/sentence into its comparable

/portable numeric keypad succession

#include <bits/stdc++.h>

utilizing namespace std;

/Function which registers the succession

string printSequence(string arr[],

string input)

{

string yield = "";

/length of info string

int n = input.length();

for (int i=0; i<n; i++)

{

/Checking for space

on the off chance that (input[i] == ' ')

yield = yield + "0";

else

{

/Calculating record for each

/character

int position = input[i]-'A';

yield = yield + arr[position];

}

}

/Output arrangement

return yield;

}

/Driver work

int principle()

{

/putting away the arrangement in cluster

string str[] = {"2","22","222",

"3","33","333",

"4","44","444",

"5","55","555",

"6","66","666",

"7","77","777","7777",

"8","88","888",

"9","99","999","9999"

};

string input = "KODSSFORKOODS";

cout << printSequence(str, input);

return 0;

}

Yield :

433335577773336667774333355777
by (930 points)  
0 votes

CONVERT THE SENTENCE INTO ITS EQUIVALENT MOBILE NUMERIC KEYPAD SEQUENCE

 

Before new smart phones in olden days the phones were utilized for making calls to family and friends. These days’ smart phones are like supercomputers.

To convert a string into its equivalent mobile numeric keypad sequence, we take a string as input and store the equivalent keypad sequence of each letter in an array i.e., for A we store 2 (as in old mobile phones we have letter A on the numeric 2 and we press it once to get letter A) for B we store 22 (we press the numeric 2 twice to get the letter B)in the same way we find the numeric sequence for each letter and store it in a string.

 

PROBLEM STATEMENT:

 

Given a sentence in the form of a string, convert it into its equivalent mobile numeric keypad sequence.

 

EXAMPLES:

 

INPUT: HELLO WORLD

 

OUTPUT: 443355555666096667775553

 

INPUT: BEAUTIFUL

OUTPUT: 2233288844433388555

 

For obtaining a number, we need to press a number corresponding to that character for number of times equal to position of the character.

 

Eg: for character C we press number 2 three times and accordingly

 

Steps to convert a sentence into its equivalent mobile numeric keypad sequence:

 

For each character, store the sequence which should be obtained at its respective position in an array i.e., for Z, store 9999,for k store 55

For each character, subtract ASCII value of ‘A’ and obtain the position in the array pointed by the character and add the sequence stored in that array to a string.

If the character is a space, store 0.

Print the overall sequence.

 

 ALGORITHM:

 

//INPUT: String

 

//OUTPUT: Displays an equivalent mobile numeric keypad sequence.

 

    //str is used to store the sequence in an array

 

//outputstring is used to store the overall sequence

 

//inputstring is used to store the string given

 

//length stores the length of the inputstring

 

Step1: Start

 

//storing the sequence in an array

 

Step 2:Initialize str={“2”,”22”,”222,”3”,”33”,”333”,”4”,”44”,”444”,”5”,”55”,”555”,”6”,”66”,”666”,”7”,”77”,”777”,”7777”,”8”,”88”,”888”,”9”,”99,”999”“9999”}

 

Step3: Read inputstring

 

Step4: n=length of inputstring

 

Step5: for i=0 to n do

 

//check if the character is a space, add 0 to the output

 

                         if (inputstring[i]==’ ‘ then

 

                                   outputstring= outputstring+”0”

 

                         endif

 

                         else

 

// if the character is not a a space calculate index for each character by subtracting the character by A and add the sequence stored in that index to the output

 

                                   index=inputstring[i]-“A”

 

                                   outputstring= outputstring+str [index]

 

                         endelse

 

endfor

 

Step6: Display outputstring

 

Step 7: Stop

by (930 points)  
...