All pastes #2082743 Raw Edit

Dinesh Karthikesu

public java v1 · immutable
#2082743 ·published 2011-09-25 13:28 UTC
rendered paste body
/*@ Author : Dinesh Karthikesu */import java.util.Scanner;public class PyramidPrinter{    public static void main (String args [])    {        Scanner input = new Scanner (System.in);                int counter; // To count the number of rows        int userInputRows = 8; // To control the number of rows        int space;  // To control the spaces        int spaceX= 7; // To control the spaces        int print;  // To control the text that's printed        int printX = 1; // To control the text that's printed        int printObject; // What's being printed                for (counter = 1; counter < userInputRows; counter ++)        {            printObject = counter;            for (space = 0; space < spaceX; space++)            {                System.out.printf (" ");            }                        for (print = 1; print <= printX; print ++)            {                System.out.printf ("%d", printObject);                                if (print < (printX + 1)/2)                {                    printObject--;                }                                else if (print >= (printX + 1)/2)                {                    printObject++;                }            }                        printX += 2;            spaceX -= 1;            System.out.printf ("\n");                       }    }}