We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Java Output Formatting
Java Output Formatting
Sort by
recency
|
1308 Discussions
|
Please Login in order to post a comment
import java.util.Scanner;
public class Solution {
}
import java.util.Scanner;
public class Solution {
}
This can be easily done using the format specifiers to format the output %03d is used to set the padding for trailing zeros instead of whitespaces. import java.util.Scanner;
public class Solution {
}
**Can anyone explain why this code is not working, I'm only getting the first "============" line in the output **
import java.util.Scanner; class Convert { String Strconvert(String s1) { int space= 15-s1.length(),i; for(i=0;i
String Numconvert(int x) { int i=0,n; do { n=x/10; i++; } while(n>0); if(i==3) { return(Integer.toString(x)); } else { if(i==2) { return("0"+Integer.toString(x)); } else { return("00"+Integer.toString(x)); } }
}
public class Solution {
}
**Can anyone explain why this code is not working, I'm only getting the first "============" line in the output **
import java.util.Scanner; class Convert { String Strconvert(String s1) { int space= 15-s1.length(),i; for(i=0;i
String Numconvert(int x) { int i=0,n; do { n=x/10; i++; } while(n>0); if(i==3) { return(Integer.toString(x)); } else { if(i==2) { return("0"+Integer.toString(x)); } else { return("00"+Integer.toString(x)); } }
}
public class Solution {
}