float i = 55 ;
float y = 23 ;
float u = i / y ;
System.out.println(u);

i want to print u Round to five decimal places how i can do this approximation ?

Recommended Answers

All 4 Replies

Look for a concept called NumberFormat in Java. It will solve your issue.

Member Avatar for hfx642

Look up Math.round.
You'll have to do a calculation before AND after...
but I have to leave SOME work for you to do.

Look for a concept called NumberFormat in Java. It will solve your issue.

thank u NumberFormat work :)

Look up Math.round.
You'll have to do a calculation before AND after...
but I have to leave SOME work for you to do.

math.round is work but not give me the required solution that better to use NumberFormat but thank for try to help me :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.