Q:

Java program that will print in reverse ladder form based on user input

I am beginner in Java programming and I want to print characters based on user input but I am not getting the right output.
    String z;
    double x;
    double c;
    double v;

    System.out.print("Input character(s): ");
    z = MNL.next();
    System.out.print("Input range: ");
    v = Integer.parseInt(reader.readLine());

    for(x=1; x<=v; x++)
    {
        for(c=1; c<=x; c++)
        {
            System.out.print(" "+z);

        }
        System.out.println(" ");

        {
            for(x=1; x>v; x--)
            {   
                for (c=1; c<x; c++)
                {
                    System.out.print(" "+z);

                }
                    System.out.println(" ");

        }

        }
    }
 }

The output I am getting:
Input character(s): JSP

Input range: 10
JSP
JSP JSP
JSP JSP
JSP JSP
JSP JSP
JSP JSP
JSP JSP
JSP JSP
JSP JSP
JSP JSP

The output should be:
Input character(s): JSP

Input range: 10
JSP
JSP JSP
JSP JSP JSP
JSP JSP JSP JSP
JSP JSP JSP JSP JSP
JSP JSP JSP JSP
JSP JSP JSP
JSP JSP
JSP

A:

I don't know what your algorithm specifies but this is a solution that produces your expected results.
   public static void main(String[] args) {
    String word;
    int range;

    Scanner input = new Scanner(System.in);

    System.out.println("Input characters");
    word = input.nextLine();
    System.out.println("Input range");
    range = Integer.parseInt(input.nextLine());

    //Ascending
    int rows = range/2;
    for(int i=0; i<rows; i++){
        for(int k=0; k<=i; k++){
            System.out.print(word + " ");
        }
        System.out.println();
    }

    //Descending
    for(int i=rows-1; i>0; i--){
        for(int k=0; k<i; k++){
            System.out.print(word + " ");
        }
        System.out.println();
    }
}

