# Java BigDecimal Hacker Rank Solution

Hello coders, In this post, you will learn how to solve Java BigDecimal Hacker Rank Solution. This problem is a part of the Java programming series.

One more thing to add, don’t straight away look for the solutions, first try to solve the problems by yourself. If you find any difficulty after trying several times, then look for the solutions.

## Java BigDecimal Hacker Rank Solution

### Objective

Java’s BigDecimal class can handle arbitrary-precision signed decimal numbers. Let’s test your knowledge of them!

Given an array, , of  real number strings, sort them in descending order — but wait, there’s more! Each number must be printed in the exact same format as it was read from stdin, meaning that  is printed as , and  is printed as . If two numbers represent numerically equivalent values (e.g., ), then they must be listed in the same order as they were received as input).

Complete the code in the unlocked section of the editor below. You must rearrange array ‘s elements according to the instructions above.

Input Format

The first line consists of a single integer, , denoting the number of integer strings.
Each line  of the  subsequent lines contains a real number denoting the value of .

Constraints

• Each  has at most  digits.

Output Format

Locked stub code in the editor will print the contents of array  to stdout. You are only responsible for reordering the array’s elements.

Sample Input

``````9
-100
50
56.6
90
0.12
.12
02.34
000.000
``````

Sample Output

``````90
56.6
50
02.34
0.12
.12
000.000
-100``````

### Java BigDecimal Hacker Rank Solution

```import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int N = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
int i;
for(i=1;i<=10;i++)
{
System.out.println(+N +" x "+i+" = "+N*i);
}
scanner.close();
}
}```

Disclaimer: The above Problem (Java BigDecimal) is generated by Hackerrank but the Solution is Provided by Chase2Learn. This tutorial is only for Educational and Learning purposes. Authority if any of the queries regarding this post or website fill the following contact form thank you.

Sharing Is Caring