Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RaviShankarOjhaRefactored {
- public static void main(String[] args) {
- printValues(7);
- }
- protected static void printValues(final int topValue) {
- int topMultiplier = (topValue > 0) ? (topValue / 2 + 2) : 1;
- for (int lastNumberOfLine = topValue; lastNumberOfLine >= 0; --lastNumberOfLine) {
- final boolean isOdd = (lastNumberOfLine % 2 != 0);
- final boolean isZero = (lastNumberOfLine == 0);
- final boolean printThisLine = (isOdd || isZero);
- if (printThisLine) {
- for (int thisMultiplier = topMultiplier; thisMultiplier > 0; --thisMultiplier) {
- final int product = lastNumberOfLine * thisMultiplier;
- final int displayValue = (product == 6) ? 5 : product;
- System.out.print(displayValue + " ");
- }
- --topMultiplier;
- System.out.println();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment