Ask your own question, for FREE!
Computer Science 5 Online
OpenStudy (anonymous):

JAVA CODE . Will give medal I'm writing a code that asks for user input in the main class and in a tester class I need to call on that user input and display a statement regarding the input with it formatted to only 2 decimal points, so I'd use System.out.printf("% and usually say if the number was 5.25 i'd put System.out.printf("%4.2f"); but since java is accomodating when using printf and doesn't cut off part of the number to the left of the decimal, it doesn't matter if i put "%6.2f" or "%1.2f" right? or is that not true?

OpenStudy (anonymous):

meaning if my user enters something like 1670.78932 and my code reads System.out.printf("%2.2f"); it would still print as "1670.78" right?

OpenStudy (anonymous):

I believe so.

OpenStudy (anonymous):

Hey @V1r3z do you know Java? I'd love to run a few things by you and see your opinion if you do

OpenStudy (anonymous):

Yes I'm pretty knowledgeable with Java.

OpenStudy (woodrow73):

Mhm, if the width is less than the number, the width will default to the number's size. You can see more on the format here: http://openstudy.com/users/woodrow73#/updates/56e04d06e4b0de40e34f1c5d https://www.cs.colostate.edu/~cs160/.Spring16/resources/Java_printf_method_quick_reference.pdf

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Mari103: How to pop out like a Jacc In the box
7 hours ago 0 Replies 0 Medals
Breathless: Spooky witch but cute
14 hours ago 3 Replies 0 Medals
Arriyanalol: help
14 hours ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
1 day ago 5 Replies 4 Medals
Jaded012023: Please tell me what you all think of this song
17 hours ago 6 Replies 1 Medal
Arriyanalol: bro how
17 hours ago 2 Replies 3 Medals
Arriyanalol: cant wait for the new bluey movie in 2027
1 day ago 12 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!