java - ANDROID: Converting inputted numbers to words -


Our assignment states that we write a program that will input a number up to 6 digits and convert the numbers into words. East: 123 = One hundred twenty three I'm cool! Then I found this site but I do not really know how to change it in Android.

Please help me ..

Here's my main activity. Xml:

  package com.example.torres; Importroid.os.Bundle; Import android.support.v7.app.ActionBarActivity; Import android.view.View; Import android.view.View.OnClickListener; Import android.widget.Button; Import android.widget.EditText; Public Class Main Activity ActionBarActivity Expanded {@ Override Protected Zero (Bundle Saved Instance) {super.onCreate (SavedInstanceState); setContentView (R.layout.fragment_main); Find last edit test number = (edit text) VVBIID (RID Editlet 1); Find the last edit text result = (edit text) ViewById (R.id.editText2); Button btnConvert = (button) findViewById (R.id.button1); Click on BtnConvert.setOnClickListener (New OnClickListener () {@Override Public Zero (see ARG0) {String number = numbers .getText (). ToString (), try the last long number = tall.Parslong (number); string Returns = word convert (number);} catch (number format exposition e) {//Toast.makeToast (free number or empty number ", toast.)}}});}}   

And here is my word. Java

  package com.example.torres; import java.text.DecimalFormat; public word word {n} G stable last string [] tensNames = {"", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"}; Fixed last string [] numNames = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" Public words () {} Public static string Convert LessThanOneThousand ("eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"} Int number) {string soFar; if (number% 100 & lt; 20) {soFar = numNames [number% 100]; numbers / = 100; } And {soFar = numnames [number% 10]; Number / 10 = 10; soFar = tensNames [number% 10] + forefather; Number / 10 = 10; } If return (number == 0) sofar; Return numbers [number] + "hundred" + suzer; } Public static string conversion (long number) {9999 99 99 99 (number == 0) {return "zero"; } String snumber = long.stustring (number); // pad with "0" string mask = "000000000000"; Decimalable df = new passphrase (mask); Snumber = df.format (number); // XXXnnnnnnnnn int billionths = integer Prism (snumber.substring (0,3)); // nnnXXXnnnnnn int millionss = integer PRIIINant (Sn's busting (3,6)); // nnnnnnxxnnn int hundred thousand = integer Prisinant (sn's busting (6 9)); // nnnnnnnnnXXX int thousands = integer Parascent (snumber.substring (9, 12)); String trillion; Switches (Arabs) {Case 0: Trade Bills = ""; break; Case 1: Business Bills = Convert Lesethoun Thousand (Arab) + "Arab"; break; Default: TradeBillings = convert Lesotho On (Arab) + "Arab"; } String result = trade bills; String trimmilians; Switch (millions) {case 0: tradMillions = ""; break; Case 1: Business milions = convert Lesotho over thousand (millions) + "million"; break; Default: Treadmillions = convert Lesotho over thousand (millions) + "million"; } Result = results + trimmilians; String transgap hundred thousand; Switch (Hundred Thousand) {Case 0: tradHundredThousands = ""; break; Case 1: Business hundred seventy thousand = "one thousand"; break; Default: Trend Thousands of convert = thousandthous thousand (hundred thousand) + "thousand"; } Result = results + thousands of deals; String Transeoushausand; Transousehausand = convert to thousandthon (thousands); Results = Results + BusinessHouse; // Remove additional locations! Return results. Rare Sub ("^ \\ s +", "") .replaceAll ("\\ b \\ s {2,} \\ b", "");}}   

The only problem is that there is nothing like this

You for the English number Create separate classes as in the example link.

And you just have to call in your button click

  string returns_val_in_enfil = englishnumber tab Convert (YOUR_NUMBER_TO_CONVERT);   

Enter image details here

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -