In general, the essence of the question is

incoming data Double type numbers 20 000 000 total amount

3333333.33 VAT from the amount

treatment

20 000 000 - 3333333.33 the amount without VAT

result 1.666666667E7

As in the calculator, my expectations User understandable format 16 666 666.7

Prompt class for mathematical calculations on java

  • Use integer data types or BigDecimal - Maxim
  • one
  • There are several different questions in your question: 1) How to output floating point numbers. For this, there are methods String.format() and PrintStream.format() . Read about them help. 2) How to store and process moneys. It depends on the task, you can often do simple double , if you can not, read the link in the next comment. 3) What class to use for mathematical calculations. For this there is a class java.lang.Math , usually it is enough. If you want to get more detailed answers, ask questions more specifically and one by one. Read www.stackoverflow.com/help/how-to-ask - m. vokhm

1 answer 1

To display the number, use DecimalFormat . For details, see the documentation for the Mathematical Computation class java.lang.Math , also see StrictMath