44 lines
823 B
Java
44 lines
823 B
Java
|
|
public class Format {
|
|
|
|
public static String padword(String word, int pad) {
|
|
|
|
String result = ">>"+word;
|
|
if (result.length() >= pad-2) {
|
|
result += "<<";
|
|
}
|
|
else {
|
|
while(result.length() <= pad-2) {
|
|
result += "-";
|
|
}
|
|
result += "<<";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static String midpadword(String word, int pad) {
|
|
|
|
String result = word;
|
|
if (result.length() >= pad-4) {
|
|
result =">>" + result + "<<";
|
|
}
|
|
else {
|
|
while(result.length() <= pad-4) {
|
|
result = "-" + result + "-";
|
|
}
|
|
result =">>" + result + "<<";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static void pad(int input) {
|
|
|
|
String result = "#";
|
|
|
|
while(result.length() < input) {
|
|
result += "#";
|
|
}
|
|
System.out.println(result);
|
|
|
|
}
|
|
} |