Monday's Programming Question
I've had a couple of questions about formatting Strings recently so this week's programming question is around the System.out.printf method and the value of Math.PI.
Using the printf method can you create formatted strings that display Math.PI to:
- match the output of
System.out.println(Math.PI);
- only have two decimal places
- have two decimal places and a positive sign (i.e., "+")
- make the calculation of 1-Math.PI have two decimal places and a negative sign (i.e,"-")
- have three leading zeros
To add to the formatting fun can you use the printf method to display the number 1234 as a denary number, a hexadecimal number, an octal number and finally as a denary number with five leading spaces.


This is a completely useles pseydo-article.
And shows that the author is thirsty for some sort of IT-recognition but doesnt have the necessary competences.
Apologies if you find the question unhelpful, but for programmers just starting out formatting a string is useful knowledge. These questions are simply designed to get those who are interested to try out a few Java programming exercises.