How To Create Right Border
Algorithm
1. Define the string value of the cell (parameter
2. Define the space width of the cell (parameter)
3. Ensure that value is never null. If it is null then fill it with empty space
4. Calculate the length of value
5. Calculate the difference of spaceWidth and valueLength
6. Create a consecutive space character (" ") as many as the difference.
7. Add "|" at the end
8. Return the concatenated consecutive space and "|" as a return value
Query :
public static String createRightBorder(String value, int spaceWidth) {
int valueLength = value.length();
int spaceCount = spaceWidth - valueLength;
String rightBorder = "|";
for (int i = 0; i < spaceCount; i++) {
rightBorder = " " + rightBorder;
}
return rightBorder;
}
Hopefully it is useful
Algorithm
1. Define the string value of the cell (parameter
2. Define the space width of the cell (parameter)
3. Ensure that value is never null. If it is null then fill it with empty space
4. Calculate the length of value
5. Calculate the difference of spaceWidth and valueLength
6. Create a consecutive space character (" ") as many as the difference.
7. Add "|" at the end
8. Return the concatenated consecutive space and "|" as a return value
Query :
public static String createRightBorder(String value, int spaceWidth) {
int valueLength = value.length();
int spaceCount = spaceWidth - valueLength;
String rightBorder = "|";
for (int i = 0; i < spaceCount; i++) {
rightBorder = " " + rightBorder;
}
return rightBorder;
}
Hopefully it is useful



0 komentar:
Posting Komentar