Update Problem031.java

Fixed code for readability