Word representation of numbers

Numbers in words are composed normally with the assistance of the English alphabet. For instance, 10,00,000 or 1,000,000 in words is read as 10 Lakhs or One million. In the early stage, numbers were used using Roman numbers and this was invented by the Romans. For example, the number 1 was represented as I, the number 2 was represented as II, the number 3 was represented as III, the number 4 was represented as IV, and many more roman numbers like M, L, and C were used. Here we will figure out how to compose the numbers from 1 to 100 using words. With the help of this article, kids can start spelling out from numbers 1 — 1000 in words.

Around the world, English is the most well-known language and it is used extensively to educate students. Therefore, in this article, we will be learning the numbers or numerals in English. Aside from English, these numbers could be written in different dialects too — like Hindi, Kannada, Tamil, Gujarati, French, German, etc.

Numbers are the foundation of Mathematics. Every single idea and concept we learn in Mathematics has numbers included in them. They are utilized for different sorts of calculations. There are additionally various kinds of numbers, which are taught in the Number system chapter. These numbers can be spoken to as words, in standard structure, and using their place value form and face value form.

How to Write Numbers in Words?

Before we jump into advanced readings, let’s first learn the basics. Understand and learn the table below:

Number

In Words

0

Zero

1

One

2

Two

3

Three

4

Four

5

Five

6

Six

7

Seven

8

Eight

9

Nine

To compose any number as words, we need to check the place value and understand it. Let us learn bit by bit.

The “ones” place value can hold only one digit. The digits are zero, one, two, three, four, five, six, seven, eight, and nine.

Next, the ten’s place. It can hold numbers from 10 — 19. In words, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, and nineteen. The Last number here would be twenty.

After twenty, the number develops from so that they are written in words as thirty, forty, fifty, sixty, seventy, eighty, ninety.

The former numbers are connected with these words and referenced from one to nine. For instance, twenty-one, twenty-two, and so on.

Let us discover how to compose any given number in words with an example.

Example: Write 42 in words.

The number in one’s place is two. Hence, there are 2 ones.

The number in ten’s place is four. Hence, there are 4 tens.

Therefore, 4 tens and 2 ones = 42. This can be read as forty — two.

Converting Numbers From 1 — 100 into Words.

The Table Below will Help you Learn How to Spell Numbers in Words.

1

One

21

Twenty One

41

Forty One

61

Sixty One

2

Two

22

Twenty-Two

42

Forty-Two

62

Sixty Two

3

Three

23

Twenty Three

43

Forty Three

63

Sixty Three

4

Four

24

Twenty Four

44

Forty Four

64

Sixty Four

5

five

25

Twenty Five

45

Forty Five

65

Sixty Five

6

Six

26

Twenty Six

46

Forty Six

66

Sixty Six

7

Seven

27

Twenty Seven

47

Forty Seven

67

Sixty Seven

8

Eight

28

Twenty Eight

48

Forty Eight

68

Sixty Eight

9

Nine

29

Twenty Nine

49

Forty Nine

69

Sixty Nine

10

Ten

30

Thirty

50

Fifty

70

Seventy

11

Eleven

31

Thirty One

51

Fifty One

71

Seventy One

12

Twelve

32

Thirty Two

52

Fifty Two

72

Seventy Two

13

Thirteen

33

Thirty Three

53

Fifty-Three

73

Seventy Three

14

Fourteen

34

Thirty Four

54

Fifty Four

74

Seventy Four

15

Fifteen

35

Thirty Five

55

Fifty Five

75

Seventy Five

16

Sixteen

36

Thirty Six

56

Fifty Six

76

Seventy Six

17

Seventeen

37

Thirty Seven

57

Fifty Seven

77

Seventy Seven

18

Eighteen

38

Thirty Eight

58

Fifty Eight

78

Seventy Eight

19

Nineteen

39

Thirty Nine

59

Fifty Nine

79

Seventy Nine

20

Twenty

40

Forty

60

Sixty

80

Eighty

81

Eighty One

82

Eighty Two

83

Eighty Three

84

Eighty Four

85

Eighty Five

86

Eighty Six

87

Eighty Seven

88

Eighty Eight

89

Eighty Nine

90

Ninety

91

Ninety One

92

Ninety Two

93

Ninety Three

94

Ninety Four

95

Ninety Five

96

Ninety Six

97

Ninety Seven

98

Ninety Eight

99

Ninety Nine

100

One Hundred

One to Hundred in Words

One to Hundred in Words

Previously, we learned how to spell from one to one hundred. Now, to write to one thousand, you need to repeat the terms of every hundredth number. Like 201 is read as two hundred and one and till 299 which is read as two hundred and ninety nine and this continues till nine hundred and ninety nine. Now, after nine hundred and ninety nine comes in 1000. 1000 in words is spelled as one thousand. The table that is given below is a reference table which helps you spell till one thousand.

Number

In Words

100

Hundred

200

Two Hundred

300

Three Hundred

400

Four Hundred

500

Five Hundred

600

Six Hundred

700

Seven Hundred

800

Eight Hundred

900

Nine Hundred

1000

One Thousand or Thousand

Examples

Question 1: Write 66 in words.

Solution: The number in one’s place is six. Hence, there are 6 ones.

The number in ten’s place is six. Hence, there are 6 tens.

Therefore, 6 tens and 6 ones = 66. This can be read as sixty — six.

Question 2: Write 87 in words.

Solution: The number in one’s place is seven. Hence, there are 7 ones.

The number in ten’s place is eight. Hence, there are 8 tens.

Therefore, 8 tens and 7 ones = 87. This can be read as eighty-seven.

Practice Questions

Q 1. What is the numerical form of “Seven hundred seventy-eight”

Ans: 778

Q 2. Give the Number Name for 562

Ans: Five hundred sixty-two

Q3. Write the expanded form and then name the number 908

Ans: 900 + 8. Nine Hundred Eight.

Summary:

Numbers in words are written using the English alphabet. Numbers can be expressed both in words and figures. Numbers in words can be written for all the natural numbers, based on the place value of digits, such as ones, tens, hundreds, thousands, and so on. A few, examples are 88 written as Eighty-eight, 56 written as Fifty-six, and so on. In this article, we have simplified all the rules that are to be followed when writing numbers in words.

Numbers in Words is writing the numbers in alphabetical form instead of digits. There are various systems to write numbers in words. After reading this article, you can write whole numbers in words, and write numbers in word form in standard form. We will primarily focus on the Indian & International number system of writing numbers in words in English, with their Rules, Tricks to remember and write spellings. You can learn to spell numbers in words 1 to 100 with Solved Examples and FAQs.

What is Number in Words?

Alphabetical form of numbers is called writing numbers in words. These are numbers written in words as the name implies. In the English language, the number 100, for example, is written as one hundred. All natural numbers, such as ones, tens, hundreds, thousands, and so on, can be represented in words based on the place value of their digits.

What is a Number Name?

Number name is the method of representing numbers in words. The alphabetical form of numbers is called number words. These are numbers written in words as the name implies. In language, the number 100, for example, is written as one hundred. All natural numbers, such as ones, tens, hundreds, thousands, and so on, can be represented as number names based on the place value of their digits.

Examples: 128 = 100 + 20 + 8. One hundred and twenty-eight is the number name of 128.

412 = 400 + 10 + 2 = 400 + 10 + 2 = 400 + 10 + 2 = 400 + 10 + 2 = 400 + 10 + 2 = 400 + 10 + 2 = 400 + 12. As a result, the number 412’s name is Four Hundred and Twelve.

685 = 600 + 80 + 5. = 685 = 600 + 80 + 5. Six hundred eighty-five is the number name for 685.

List of Number Names from 1 to 20

Here is a list of Numbers in Words from 1 – 20. A 1-20 number chart is a great way to teach your youngster numbers and practise one-to-one correspondence. The numbers 1 through 20 are represented in the graphic. Each number has a term for it, as well as a number of visuals that correspond to it.

List of Number Names from 1 to 20

List of Numbers in Words from 1 to 20
1 – One 2 – Two 3 – Three 4 – Four 5 – Five
6 – Six 7 – Seven 8 – Eight 9 – Nine 10 – Ten
11 – Eleven 12 – Twelve 13 – Thirteen 14 – Fourteen 15 – Fifteen
16 – Sixteen 17 – Seventeen 18 – Eighteen 19 – Nineteen 20 – Twenty

List of Number Names from 1 to 50

Here’s a list of Numbers in Words from 1 to 50. 1-50 number chart is a great way to teach and learn number names.

Number In Words 1 – 50
1 One 2 Two 3 Three 4 Four 5 Five
6 Six 7 Seven 8 Eight 9 Nine 10 Ten
11 Eleven 12 Twelve 13 Thirteen 14 Fourteen 15 Fifteen
16 Sixteen 17 Seventeen 18 Eighteen 19 Nineteen 20 Twenty
21 Twenty-one 22 Twenty-two 23 Twenty-three 24 Twenty-four 25 Twenty-five
26 Twenty-six 27 Twenty-seven 28 Twenty-eight 29 Twenty-nine 30 Thirty
31 Thirty-one 32 Thirty-two 33 Thirty-three 34 Thirty-four 35 Thirty-five
36 Thirty-six 37 Thirty-seven 38 Thirty-eight 39 Thirty-nine 40 Forty
41 Forty-one 42 Forty-two 43 Forty-three 44 Forty-four 45 Forty-five
46 Forty-six 47 Forty-seven 48 Forty-eight 49 Forty-nine 50 Fifty

List of Number Names from 1 to 100

Here’s a list of Numbers in Words from 1 – 100. A 1-100 number chart is a great way to teach and learn number names.

List of Number Names from 1 to 100
1 one 2 two 3 three 4 four 5 five
6 six 7 seven 8 eight 9 nine 10 ten
11 eleven 12 twelve 13 thirteen 14 fourteen 15 fifteen
16 sixteen 17 seventeen 18 eighteen 19 nineteen 20 twenty
21 twenty- one 22 twenty- two 23 twenty- three 24 twenty- four 25 twenty- five
26 twenty- six 27 twenty- seven 28 twenty- eight 29 twenty- nine 30 thirty
31 thirty- one 32 thirty- two 33 thirty- three 34 thirty- four 35 thirty- five
36 thirty- six 37 thirty- seven 38 thirty- eight 39 thirty- nine 40 forty
41 forty- one 42 forty- two 43 forty- three 44 forty- four 45 forty- five
46 forty- six 47 forty- seven 48 forty- eight 49 forty- nine 50 fifty
51 fifty- one 52 fifty- two 53 fifty- three 54 fifty- four 55 fifty- five
56 fifty- six 57 fifty- seven 58 fifty- eight 59 fifty- nine 60 sixty
61 sixty- one 62 sixty- two 63 sixty- three 64 sixty- four 65 sixty- five
66 sixty- six 67 sixty- seven 68 sixty- eight 69 sixty- nine 70 seventy
71 seventy- one 72 seventy- two 73 seventy- three 74 seventy- four 75 seventy- five
76 seventy- six 77 seventy- seven 78 seventy- eight 79 seventy- nine 80 eighty
81 eighty- one 82 eighty- two 83 eighty- three 84 eighty- four 85 eighty- five
86 eighty- six 87 eighty- seven 88 eighty- eight 89 eighty- nine 90 ninety
91 ninety- one 92 ninety- two 93 ninety- three 94 ninety- four 95 ninety- five
96 ninety- six 97 ninety- seven 98 ninety- eight 99 ninety- nine 100 one hundred

How to write a Number in Words using International System?

It is based on the International Place Value Chart. The steps to write numbers in International System are as follows.

Step 1: First, we begin from the right side and insert commas after every three digits.

Step 2: Each group is assigned a period starting from the right-hand side as ones, thousands, and millions, followed by billions and so on. This becomes the place value of the digits.

Step 3: Identify the face value of each digit. For example, if a number is 56, the face value of 6 is simply 6, however, if a number is 567, the place value is in the tens place, which is 60.

Step 4: We add up the amounts in the same period. For example, in 27,000 we have a place value of 2 as twenty thousand and 7 as seven thousand. Together it becomes 20 + 7 i.e. twenty-seven thousand.

Step 5: Now write down the face value of each number starting from the left-hand side.

How to write a Number in Words using Indian System?

It is based on the Indian Place Value Chart. The Indian System is a little different from the International system. But it can be easily learnt below and you can convert numbers to words in Indian rupees.

Step 1: First, we begin from the right side and insert commas. The first group is after three-digit and after that every two digits.

Step 2: Each group is assigned a period starting from the right hand side as ones, thousands, lakhs, crores and so on. This becomes the place value of the digits.

Step 3: Identify the face value of each digit. For example, if a number is 56, the face value of 6 is simply 6, however, if a number is 567, the place value is in the tens place, which is 60.

Step 4: We add up the amounts in the same period. For example, in 27,000 we have a place value of 2 as twenty thousand and 7 as seven thousand. Together it becomes 20 + 7 i.e. twenty-seven thousand.

Step 5: Now write down the face value of each number starting from the left-hand side.

Rules of Writing Numbers in Words

  • In any Numbering System, we always start on the right side. The number is divided into periods, each of which is read separately.
  • Small numbers ranging from one to ten (or one to nine, depending on the style guide) should normally be spelt out in writing.
  • Numbers greater than 10 are written as numerals.
  • All compound numerals from twenty-one to ninety-nine should be hyphenated.

Tips to Write Numbers in Words

  • Using simple Number/Rhyme pictures associated with a storey is the easiest, but the least reliable, approach to recalling numbers.
  • A preferable method is to employ a simple peg system, in which you can correlate numerals from the Number/Rhyme System with positions structured using the Alphabet System.

Solved Examples of Numbers in Words

Example 1: Write the numbers in the International and Indian place-value system place commas and the name of the following numbers.

Solution: 721336598 in the Indian system:

Let’s interpret the number by arranging the digits in the Indian place value system from left to right according to their locations as ones, tens, hundreds, thousands, and so on.

The number is written as 72,13,36,598 and read as

Seventy-two crores thirteen lakh thirty-six thousand five hundred and ninety-eight.

721336598 in the International System:

Now, in the international place value system, arrange the digits from left to right according to their locations as ones, tens, hundreds, thousands, and so on, and read and write the number.

The number is written as 721,336,598

Let’s read the number by arranging the digits from left to right.

Seven hundred and twenty-one million, three and thirty-six, hundred thousand five hundred and ninety-eight.

Example 2: Using the International system, write the number; Six million, four hundred and eleven thousand, two hundred and sixty.

Solution: 6,411,260.

Example 3: Using the international system, read the number 7456123.

Solution: 7456123- Seven million Four Hundred Fifty-six thousand one hundred twenty-three.

Example 4: Write the number in words: 12,367,169.

Solution: Twelve million, three hundred and sixty-seven thousand, one hundred and sixty-nine.

Example 5: Write seven hundred forty-three million eight hundred thirteen thousand two hundred fifty-six in the numeral form using the international system.

Solution: 743,813,256.

Hope this article on Number in Words was informative. Get some practice of the same on our free Testbook App. Download Now!

FAQs on Number in Words

Q.1 How do you write numbers in words using the International System?

Ans.1

  • Step 1: First, we begin from the right side and insert commas after every three digits.
  • Step 2: Each group is assigned a period starting from the right hand side as ones, thousands, and millions, followed by billions and so on. This becomes the place value of the digits.
  • Step 3: Identify the face value of each digit. For example, if a number is 56, the face value of 6 is simply 6, however, if a number is 567, the place value is in the tens place, which is 60.
  • Step 4: We add up the amounts in the same period.
  • Step 5: Now write down the face value of each number starting from the left hand side.

Q.2 How do you write numbers in words using the Indian System?

Ans.2

  • Step 1: First, we begin from the right side and insert commas. The first group is after three-digit and after that every two digits.
  • Step 2: Each group is assigned a period starting from the right-hand side as ones, thousands, lakhs, crores and so on. This becomes the place value of the digits.
  • Step 3: Identify the face value of each digit. For example, if a number is 56, the face value of 6 is simply 6, however, if a number is 567, the place value is in the tens place, which is 60.
  • Step 4: We add up the amounts in the same period.
  • Step 5: Now write down the face value of each number starting from the left-hand side.

For example, in 27,000 we have a place value of 2 as twenty thousand and 7 as seven thousand. Together it becomes 20 + 7 i.e. twenty-seven thousand.

Q.3 What is called 10000000000?

Ans.3 The number: 10000000000 is (10^{13}). I would call it ten million million. You could call it ten trillion. A trillion is a thousand billion.

Q.4 What is number in words?

Ans.4 Alphabetical form of numbers is called writing numbers in words. These are numbers written in words as the name implies.

Q.5 What is a number name?

Ans.5 Number name is the method of representing numbers in words. The alphabetical form of numbers is called number words. These are numbers written in words as the name implies.

Q.6 What are the rules of writing numbers in words?

Ans.6 The rules of writing numbers in words are:

  • In any Numbering System, we always start on the right side. The number is divided into periods, each of which is read separately.
  • Small numbers ranging from one to ten (or one to nine, depending on the style guide) should normally be spelt out in writing.
  • Numbers greater than 10 are written as numerals.
  • All compound numerals from twenty-one to ninety-nine should be hyphenated.


  • 0

   

The Different Forms of Representing Numbers

There are different ways of writing a number. We can represent a number in three different forms: 

1. The standard form

2.The word form

3. The expanded form

Representation deals with the method that allows us to express a number to someone else, and the number should be exactly understandable to others as stated.

In our daily life, if someone says the price of a toy is twenty-five dollars, it means he said the number in word form, and this way of expressing a number could be understood. Again, if a price tag on a shirt says ‘$15’, it is said to be in the standard form which is easily understandable.

The Standard Form

If we write a number in digits, separating the groups by commas, the number is said to be in the standard form. We often use the standard form to write the numbers in mathematics. It is also the easiest way of expressing the number. So, it is the most common or obvious way of expressing numbers.

For example, 

789,456   

4,555   

233     

789,450, and so on.

The Word Form

If one writes or represents a standard number in words, the form is called the word form. This is the same as when we tell a number to others.

For example, 399 is stated as three hundred ninety-nine.

586,256 in the word form is five hundred eighty-six thousand, two hundred fifty-six.

The Expanded Form

If the number is written as the summation of the place value of each digit, the number is said to be  in the expanded form.

For example, 

356 in the expanded form is 300 + 50 + 6.

Here, each digit is separated according to its place value. Then the ‘addition’ symbol is mentioned between them. This representation helps us analyze a number easily.

Example: If we take the number 842,062 and make a place value chart as,

diff1

This number can be written in three forms as,

The standard form: 842,062.

The word form: Eight hundred forty-two thousand, sixty-two.

The expanded form: 800000 + 40000 + 2000 + 60 + 2.

Solved Examples on Number Representation

Example 1: Write the number in three different forms.

8563

Solution:

diff2

The standard form: 8,563.

The word form: Eight thousand, five hundred sixty-three.

The expanded form: 8,000 + 500 + 60 + 3

Example 2: Write the number in the standard and expanded forms:

Eighty-six thousand, seven hundred and three.

Solution:

The word form is eighty-six thousand, seven hundred three.

The standard form:

diff3

The standard form: 86,703.

The expanded form: 80,000 + 6,000 + 700 + 3.

Example 3: Write in the standard and word forms.

100,000 + 30,000 + 6,000 + 500 + 50 

Solution:

The expanded form is,

100,000 + 30,000 + 6,000 + 500 + 50

The standard form: 136,550

The word form: One hundred thirty-six thousand, five hundred fifty.

Example 4: Use the number 700,000 + 5,000 + 20 + 1 to complete the check.

diff4

Solution:

The expanded form is,

700,000 + 5,000 + 20 + 1

The standard form: 705,021

The word form: Seven hundred five thousand, twenty one.

diff5

Example 5: Ava asks Liam and Mia to write “ninety-nine thousand, three hundred thirty-four” in the standard form. Who wrote the correct number? What mistake did the other make?

diff6

Solution:

The word form is ninety-nine thousand, three hundred thirty- four.

The standard form : 99,334

Therefore, Liam wrote the correct answer.

Mia has made a mistake in the tens place where instead of writing 3 she has written as 0.

diff7

Frequently Asked Questions on Number Representation

The three forms to represent a number are:

The standard form: For example, 78,562.

The word form: For example, Six hundred fifty six.

The expanded form: For example, 500 + 20 + 3.

If there is a zero in between a number while writing the number in the expanded form or in the word form, the place is skipped.

The expanded form of a number helps us understand the place value of digits clearly. It also helps while comparing two or more numbers.

Check out our other courses

Javascript Online Compiler

Write, Run & Share Javascript code online using OneCompiler’s JS online compiler for free. It’s one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler’s Javascript editor is easy and fast. The editor shows sample boilerplate code when you choose language as Javascript and start coding.

About Javascript

Javascript(JS) is a object-oriented programming language which adhere to ECMA Script Standards. Javascript is required to design the behaviour of the web pages.

Key Features

  • Open-source
  • Just-in-time compiled language
  • Embedded along with HTML and makes web pages alive
  • Originally named as LiveScript.
  • Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc.

Syntax help

variable declaration

Keyword Description Scope
var Var is used to declare variables(old way of declaring variables) Function or global scope
let let is also used to declare variables(new way) Global or block Scope
const const is used to declare const values. Once the value is assigned, it can not be modified Global or block Scope

Backtick Strings

Interpolation

let greetings = `Hello ${name}`

Multi line Strings

const msg = `
hello
world!
`

Arrays

An array is a collection of items or values.

Syntax:

let arrayName = [value1, value2,..etc];
// or
let arrayName = new Array("value1","value2",..etc);

Example:

let mobiles = ["iPhone", "Samsung", "Pixel"];

// accessing an array
console.log(mobiles[0]);

// changing an array element
mobiles[3] = "Nokia";

Arrow functions

Arrow Functions helps developers to write code in concise way, it’s introduced in ES6.
Arrow functions can be written in multiple ways. Below are couple of ways to use arrow function but it can be written in many other ways as well.

Syntax:

() => expression

Example:

const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const squaresOfEvenNumbers = numbers.filter(ele => ele % 2 == 0)
                                    .map(ele => ele ** 2);
console.log(squaresOfEvenNumbers);

De-structuring

Arrays

let [firstName, lastName] = ['Foo', 'Bar']

Objects

let {firstName, lastName} = {
  firstName: 'Foo',
  lastName: 'Bar'
}

rest(…) operator

 const {
    title,
    firstName,
    lastName,
    ...rest
  } = record;

Spread(…) operator

//Object spread
const post = {
  ...options,
  type: "new"
}
//array spread
const users = [
  ...adminUsers,
  ...normalUsers
]

Functions

function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
  console.log(`Hello ${name}!`);
}
 
greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar

Loops

1. If:

IF is used to execute a block of code based on a condition.

Syntax

if(condition){
    // code
}

2. If-Else:

Else part is used to execute the block of code when the condition fails.

Syntax

if(condition){
    // code
} else {
    // code
}

3. Switch:

Switch is used to replace nested If-Else statements.

Syntax

switch(condition){
    case 'value1' :
        //code
        [break;]
    case 'value2' :
        //code
        [break;]
    .......
    default :
        //code
        [break;]
}

4. For

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
//code  
} 

5. While

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while (condition) {  
  // code 
}  

6. Do-While

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {  
  // code 
} while (condition); 

Classes

ES6 introduced classes along with OOPS concepts in JS. Class is similar to a function which you can think like kind of template which will get called when ever you initialize class.

Syntax:

class className {
  constructor() { ... } //Mandatory Class method
  method1() { ... }
  method2() { ... }
  ...
}

Example:

class Mobile {
  constructor(model) {
    this.name = model;
  }
}

mbl = new Mobile("iPhone");

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

class Main

{

    private static final String EMPTY = «»;

    private static final String[] X =

    {

        EMPTY, «One «, «Two «, «Three «, «Four «, «Five «, «Six «,

        «Seven «, «Eight «, «Nine «, «Ten «, «Eleven «,«Twelve «,

        «Thirteen «, «Fourteen «, «Fifteen «, «Sixteen «,

        «Seventeen «, «Eighteen «, «Nineteen «

    };

    private static final String[] Y =

    {

        EMPTY, EMPTY, «Twenty «, «Thirty «, «Forty «, «Fifty «,

        «Sixty «, «Seventy «, «Eighty «, «Ninety «

    };

    // Function to convert a single-digit or two-digit number Longo words

    private static String convertToDigit(long n, String suffix)

    {

        // if `n` is zero

        if (n == 0) {

            return EMPTY;

        }

        // split `n` if it is more than 19

        if (n > 19) {

            return Y[(int) (n / 10)] + X[(int) (n % 10)] + suffix;

        }

        else {

            return X[(int) n] + suffix;

        }

    }

    // Function to convert a given number (max 9-digits) Longo words

    public static String convert(long n)

    {

        // for storing the word representation of the given number

        StringBuilder res = new StringBuilder();

        // add digits at ten million and hundred million place

        res.append(convertToDigit((n / 1000000000) % 100, «Billion, «));

        // add digits at ten million and hundred million place

        res.append(convertToDigit((n / 10000000) % 100, «Crore, «));

        // add digits at hundred thousand and one million place

        res.append(convertToDigit(((n / 100000) % 100), «Lakh, «));

        // add digits at thousand and tens thousand place

        res.append(convertToDigit(((n / 1000) % 100), «Thousand, «));

        // add digit at hundred place

        res.append(convertToDigit(((n / 100) % 10), «Hundred «));

        if ((n > 100) && (n % 100 != 0)) {

            res.append(«and «);

        }

        // add digits at ones and tens place

        res.append(convertToDigit((n % 100), «»));

        return res.toString().trim()

                .replace(«, and», » and»)

                .replaceAll(«^(.*),$», «$1»);        // remove trailing comma

    }

    // Java program to convert numbers to words

    public static void main(String[] args)

    {

        System.out.println(convert(99L));

        System.out.println(convert(1000L));

        System.out.println(convert(14632L));

        System.out.println(convert(997751076L));

        System.out.println(convert(2147483647L));

    }

}

Понравилась статья? Поделить с друзьями:
  • Word replacements for but
  • Word replacement for you
  • Word replacement for but
  • Word replace words with other
  • Word replace text as you type