# Cardinal Number in Java

In this section, we will learn what is cardinal number and also create Java programs to find the cardinal number. The cardinal number program frequently asked in Java coding interviews and academics.

## Cardinal Numbers

Cardinal numbers are used to represent the quantity. Cardinal numbers are the counting numbers (if 0 is included) that we use to do the counting. For example: 1, 2, 3, 4, …, etc. A few common statements that use the cardinal numbers are:

• My neighbor has 4
• There are 8 flowers in a flower pot.
• Abhijeet is 17 years old.
• The library of my college has 2000
• The water molecule consists of 2 atoms of Hydrogen and 1 atom of Oxygen.
• The tall person has 2 Blu-Ray players.
• S = {x, y, u, i, p, a, f, h, j, q, l}. The set S has 11

All these number 4, 8, 17, 2000, 2, 1, 2, and 11 has some meaning attached to it. It is because they represent some quantity.

Note that counting numbers are not always treated as Cardinal numbers.

There are many scenarios where counting numbers are not treated as cardinal numbers. For example, if we use the counting numbers to make a comparison, then those numbers are not treated as cardinal numbers. Consider the following statements.

• Mr X is 4 times older than Mr Y.
• Ramesh took 1 hour more time than Suresh to complete the race.
• Bullet train is 10 times faster than the express train.
• Suresh is 6 inches taller than Amresh.
• Arpita finished the race 1 second before Sumita.

Although 4, 1, 10, 6, and 1 are the counting numbers but they are not the cardinal numbers. The reason is that those numbers are not representing any quantity.

Just like comparison, numerical elements of a set are also not treated as cardinal numbers.

X = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

The set X has 10 elements. Thus, 10 is the cardinal number. However, elements 1, 2, 3, …, 10 of the set are not representing any quantity (they are just elements of set X). Therefore, 1, 2, 3, …, 10 are not cardinal numbers. Thus, we see that 10 (total number of elements) is a cardinal number as well as not a cardinal number (when treated as an element) at the same time. Therefore, every counting number may or may not be treated as a cardinal number. It completely depends on the context in which the counting numbers are used.

## Cardinal Number Java Program

The following program shows how one can distribute chocolates among children such that no one getting more than 10 chocolates at a time.

FileName: CardinalNumber.java

Output:

```The 1st child got 4 chocolates.
The 2nd child got 3 chocolates.
The 3rd child got 7 chocolates.
The 4th child got 8 chocolates.
The 5th child got 2 chocolates.
The 6th child got 10 chocolates.
The 7th child got 3 chocolates.
The 8th child got 8 chocolates.
```

The number of chocolates shown in the output is cardinal numbers.

### Feedback   